msgbartop
News, views, tips and tricks on Oracle and other fun stuff
msgbarbottom

Oracle in 3 Minutes: A Ticking Bomb

Here is the second episode of Oracle in 3 Minutes. I titled it A Ticking Bomb, but you can also call it A Sleeper Bug.


Filed in Oracle on 10 Dec 07 | Tags:


Reader's Comments

  1. |

    Solution 3:

    Reconsider your data model if you are really going to compare two columns which obviously have the same content and meaning but are of different data type…

    :-) Patrick

  2. |

    @Patrick: Sure, if you can change the data model, that will be a very good solution. But, sometimes reality hurts and you’re stuck with a model that you have no control over. I sometimes do find myself in such a situation, unfortunately, especially when I deal with FlexFields (varchar2 columns) in Oracle EBS.

  3. |

    Yeah, reality sometimes is so far way from the “ideal” world :-)

  4. |

    When trying to filter out rows, be aware that there is no guarantee about what order Oracle executes the various conditions. So you might well find that the invalid number error returns down the road when the query plan changes.

    Even if you nest the subquery, i.e.

    SELECT t1.col1, t2.col2
      FROM (SELECT t.col1 
              FROM table1 t 
             WHERE filter_out_non_numbers) t1,
           table2 t2
     WHERE t1.col1 = t2.col1
    

    there is no guarantee that the inner subquery is logically materialized before the join (and the implicit conversion) happens.

  5. |

    @Justin: Good points.

    One more thing, if the to_char is used in the WHERE clause, that will break the use of indexes which may impact performance. So, a function based index may be a good option here.

  6. |

    [...] also has the second episode of his Oracle in 3 Minutes webcast, called A Ticking Bomb, or A Sleeper [...]