Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to execute a variable in which query ia stored...
On May 3, 6:43 am, sybrandb <sybra..._at_gmail.com> wrote:
> On May 3, 12:37 pm, "sartaj..._at_gmail.com" <sartaj..._at_gmail.com> wrote:
>
> > Hello,
>
> > Can some one help me in executing a variable in oracle , in
> > that variable a simple query is stored...., as given below
>
> > begin
> > :s:='select * from employee';
> > end;
>
> > now just tell me how to get the query result by the variable...
>
> Look up 'execute immediate' of 'Native Dynamic SQL' in your
> documentation.
> If you are not prepared to do this, Oracle is not for you.
>
> --
> Sybrand Bakker
> Senior Oracle DBA
As a general rule you should use static SQL over dynamic SQL and in either case always code bind variables into your SQL rather than construct SQL using constaints for the where clause variables.
So when you look up the 'execute immediate' statement in the PL/SQL User's Guide and Reference also check into the using clause. Your current sample do not need it but when you get around to adding something like "where empno =" then it will come in handy.
HTH -- Mark D Powell -- Received on Thu May 03 2007 - 07:22:01 CDT
![]() |
![]() |