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
KC, you have expanded on the technical problem (thanks), but you did not
mention the business problem that is driving you to even attempt this
activity. As Jim pointed out, it looks like you are de-normalizing your
data, which may or may not be a bad move depending on how you plan to
make use of it. Is this an actual business problem, or an artificial
problem dreamed up by your lecturer? How about backing up a few steps
and telling us the original problem you are trying to solve? There may
be far better alternatives than the particular approach you have decided
to wrestle with.
Martin Doherty
Jim Kennedy wrote:
>bad design.
>Jim
>"K. C." <the_ada_at_hotmail.com> wrote in message
>news:be879ba7.0211160610.1d74da99_at_posting.google.com...
>
>
>>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)
>>.
>>.
>>.
>>Col20 VARCHAR2(20)
>>Fld20 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 Sun Nov 17 2002 - 17:07:56 CST