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: PL/SQL Dynamic sql

Re: PL/SQL Dynamic sql

From: anacedent <anacedent_at_hotmail.com>
Date: Sat, 12 Jun 2004 07:00:41 -0700
Message-ID: <d0Eyc.63289$tI2.62037@fed1read07>


Steve Rainbird wrote:
> Is it possible to generate what I would call Dynamic PL/SQL?
>
> What I am trying to do is the following.
>
> I want to assign a value to a variable in PL/SQL but I don't know the
> name of the variable until run time.
>
> I have tried the following (and many other variations) without
> success.
>
> declare
> exstring varchar2(500);
> varname varchar2(20);
> var number;
> begin
> var:=1;
> varname:='var';
> exstring:='begin :1 := 5; end;';
> execute immediate exstring using in out varname;
> dreamer.dream ('var=' || var);
> end;
> /

HUH?
I suspect you have a clear picture in your mind what you hope to accomplish, but I'm confused.

The EXECUTE IMMEDIATE is used to invoke an SQL statement (ONLY SQL).

It almost appears you want to decide at runtime which PL/SQL procedure needs to be invoked.
Is this correct.
If so then just use IF .. THEN.. ELSE or use the CASE statement. Received on Sat Jun 12 2004 - 09:00:41 CDT

Original text of this message

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