Re: Columns referenced by name in other columns.

From: F. Carlos Andrés <fandres_at_polar.es>
Date: 23 Oct 2002 10:34:56 -0700
Message-ID: <3e5abb2f.0210230934.223425a2_at_posting.google.com>


I´ve discovered how to do it.
I can construct a sql statement in a variable and then execute it with:

execute immediate variable_name

fandres_at_polar.es (=?ISO-8859-1?Q?F._Carlos_Andr=E9s?=) wrote in message news:<3e5abb2f.0210220727.1f4aa755_at_posting.google.com>...
> Hi there.
> I've a little problem in PL/SQL. I have to update the values of some
> columns in a table, and these columns are referenced by their names in
> the column of the table thas has the values.
>
> It's something like this:
> TABLE1(
> ID NUMBER,
> COLUMN VARCHAR2(32),
> VALUE NUMBER (10, 2)
> )
>
> TABLE2(
> ID NUMBER,
> PRICE NUMBER (10, 2),
> VAT NUMBER (10, 2),
> .
> .
> .
> ) Up to 40 columns.
>
> In TABLE1 I've a register: ID=10, COLUMN='PRICE', VALUE=10.00. That
> means that I've to change the value of the column PRICE in TABLE2 to
> 10.00 where ID=10.
> I know that I van do this witn a cursor, inserting the values of
> TABLE1 in variables vID, vCOLUMN, vValue, and with the conditionals
> if (vCOLUMN = 'PRICE')
> update TABLE2 set PRICE = vVALUE where ID = vID;
> else if (........
>
> And my question is if I can do that without writting the conditions
> for all the columns, because TABLE2 can grown in number of columns and
> then I must add new conditions for the new columns.
>
> Thanks.
>
> Paco
Received on Wed Oct 23 2002 - 19:34:56 CEST

Original text of this message