Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle's query parameter syntax equivalent to @ in SQL's
sunny076_at_yahoo.com wrote:
: Hi,
: I am new to Oracle and wonder if anyone can enlighten me. I am looking : for the syntax for parameter equivalent to @ in SQL, for example, in : "SELECT * FROM EMPLOYEES WHERE EmpID = @EmpID".
Three possibilities, not sure which corresponds
-1- within sqlplus and some other places you can have textual substitution
variables, typically using the & . syntax
sql> define wanted="what ever is wanted" sql> select * from emp where empid = &wanted. ;
parameters to sqlplus scripts are accessed as &1 &2 &3 etc
sql> select * from emp where empid = &1. ;
-2- variables maintained by the database and referenced from sql are
called bind variables, and use the : syntax
select * from emp where empid = :wanted
you may see them within sqlplus or within pl/sql code in some other places
-3- pl/sql variables are programming language variables which are
integrated into the sql syntax within pl/sql code, they do not use any
special syntax, and are recognized by the context
select something into my_var1 from emp where empid = my_var2;
--
This space not for rent. Received on Tue May 03 2005 - 19:05:42 CDT