Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL Dynamic sql
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