Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: help: Bind variables
Hi, Chris.
I'm a little confused with the difference between using a bind variable and a regular variable.
If you set a regular variable e to some value and did a select * from table where field = e, does the variable's value get substituted before the statement is parsed and stored in the SGA? Is that the advantage of bind variables - queries using them get parsed with the bind variables in them and that's why they're better in some cases? So, in your example, doing the 2 selects with a regular variable e instead of a bind variable :e would require both selects to be parsed while doing this with a bind variable would only require the query to be parsed the first time?
Thanks for shedding whatever light you can on this, -Jeff
On Wed, 06 Oct 1999 10:42:25 -0400, Christopher Beck <clbeck_at_us.oracle.com> wrote:
>On Wed, 06 Oct 1999 08:52:06 GMT, flap5_at_my-deja.com wrote:
>
>>1. Can I use bind variables in normal SQL statements?
>>
>>2. If so, how can I declare the value of them?
>
>Do you mean from sql*plus?
>
>If yes then try this...
>
>scott_at_8i> var e number
>scott_at_8i> exec :e := 7788;
>PL/SQL procedure successfully completed.
>
>scott_at_8i> select ename from emp where empno = :e;
>
>ENAME
>----------
>SCOTT
>
>scott_at_8i> exec :e := 7839;
>PL/SQL procedure successfully completed.
>
>scott_at_8i> select ename from emp where empno = :e;
>
>ENAME
>----------
>KING
>
>
>Hope this helps.
>
>
>chris.
>
>
>
>>
>>Thanks
>>
>>
>>Sent via Deja.com http://www.deja.com/
>>Before you buy.
>
>
>--
>Christopher Beck
>Oracle Corporation
>clbeck_at_us.oracle.com
>Reston, VA.
>----------------------------------------------------------------------------
>Opinions are mine and do not necessarily reflect those of Oracle Corporation
Received on Wed Oct 06 1999 - 13:17:15 CDT
![]() |
![]() |