Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: create dynamic variables
Martin T. wrote:
> mgmonzon wrote:
> > Hi Everybody,
> >
> > Is posible to create dynamic variables in a PL/SQL procedure?
> > (snip)
> > Sample :
> >
> > Create or replace read_variables as
> > Begin
> > for reg in (select VAR_NAME, VAR_VALUE from TABLE_VARIABLE ) loop
> > <create variable defined in the field VAR_NAME in TABLE_VARIABLE> ;
> > <Assign value using the field VAR_VALUE in TABLE_VARIABLE> ;
> > End Loop ;
> > End ;
> >
> > Is possible do that?
> >
>
> No. This is not possible. (As in all other programming languages I
> know.)
> Why would you want to do such a thing? It doesn't make too much sense
> too me :-)
>
> best,
> Martin
Well, a lot of applications today use built-in scripting of different sorts, which allows end users to extend them the way they want without the need to ask app developers for required functionality. I think OP looks for something similar in PL/SQL. There's Dynamic SQL to the rescue, though it will require a bit of architecting before coding... What the OP has now is not sufficient as I noted in my other post.
And by the way, it's possible to build and execute code dynamically in quite a few languages. Classic interpreted BASIC is one good example - you can dynamically define subprograms and call them. JavaScript and VBScript allow this, too. In fact, any interpreted language at least potentially allows dynamic code generation and execution. PL/SQL is not really an interpreted language per se, but still allows dynamic code generation and execution via Dynamic SQL (DBMS_SQL and EXECUTE IMMEDIATE.) Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com
Received on Wed Aug 09 2006 - 11:27:29 CDT