Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to execute a variable in which query ia stored...

Re: How to execute a variable in which query ia stored...

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 3 May 2007 05:22:01 -0700
Message-ID: <1178194921.257287.92800@n59g2000hsh.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US