Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Variable vs hardcoded value in SQL query

763899May 12 2010 — edited May 13 2010
Hi Gurus,

I have a SQL query inside a function that looks similar (i'm showing the "where" clause here only) to the below:

WHERE ID = variable_id (by the way this two have exactly the same type, number(20))

and

WHERE ID = 100

In the first option that uses variable it takes 4 secs to complete the query, while the second one that uses hardcoded value completes in milliseonds. Im new to oracle but been to other dbms and havent seen such behaviour. Anyone encountered or know what maybe the cause? I thought of not pasting here the explain plan since its just a question of variable vs hardcoded value.

rgds.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 10 2010
Added on May 12 2010
6 comments
2,019 views