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: create dynamic variables

Re: create dynamic variables

From: DA Morgan <damorgan_at_psoug.org>
Date: Wed, 09 Aug 2006 13:18:18 -0700
Message-ID: <1155154699.528578@bubbleator.drizzle.com>


mgmonzon wrote:
> Hi Everybody,
>
> Is posible to create dynamic variables in a PL/SQL procedure?
>
> This is my problem, I have a table called TABLE_VARIABLE with this
> values :
>
> # VAR_NAME VAR_VALUE
> ------- --------------- ------------------------
> 1 SALARY 1000
> 2 DISCOUNT 300
> 3 NET (SALARY - DISCOUNT)
>
>
> I want create a procedure where the variables names should be the same
> name defined in the table TABLE_VARIABLE.
> The user is able to create ne records and new variables names an the
> names should be processed like a pl/sql variables in order to store
> the result information in other table.
>
> 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?
>
>
> Mgmonzon

You can do what you want but my instinct is to lecture you on what appears to be a really bad idea and question what business rule has led to you think this is a something you want to implement.

That said look at utilizing the DBMS_DDL built-in package. You can use (provided you have 10g and you seem to think version information unimportant) the CREATE_WRAPPED package to write wrapped code on-the-fly. Of course it can also be done with NDS, DBMS_SQL, or

... Now back to the fact that I think this is a terribly misguided idea and question why anyone thinks doing this makes sense ....

Can you explain the point of this design?

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Wed Aug 09 2006 - 15:18:18 CDT

Original text of this message

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