Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Newbie needs help with dynamic column name in SQL
Hi Martin,
Ok. I have a table called tableA:
ID NUMBER
Fld1 VARCHAR2(20)
Val1 VARCHAR2(500)
Where ID has values from 1 to 20, and Fld1 and Val1 could be anything.
Now, I have another table tableB:
Col1 VARCHAR2(20) Fld1 VARCHAR2(500) Col2 VARCHAR2(20) Fld2 VARCHAR2(500) .
Bascially I want to move the data from tableA to tableB. In tableA, records with ID = 1 would go into the Col1 and Fld1 columns in tableB, records with ID = 2 would go into the Col2 and Fld2 columns in tableB.
I'm using Oracle8i 8.1.6.
Thanks,
KC
Martin Doherty <martin.doherty_at_elcaro.moc> wrote in message news:<DRjB9.10$GH3.83_at_news.oracle.com>...
> Is your table name or WHERE clause also dynamic? Because if it isn't I
> don't see any point in updating the same rows 20 times in a loop - just
> issue a single UPDATE that updates all 20 columns at the same time.
>
> Maybe you could expand a little bit on the business problem that is
> causing you to ask the question, and possibly even mention the version
> of Oracle you are working with (Yes, it DOES matter).
>
> Martin Doherty
>
Received on Sat Nov 16 2002 - 08:10:18 CST