Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: column name order & insert into tab select

Re: column name order & insert into tab select

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: 2000/03/03
Message-ID: <952106021.21825.2.pluto.d4ee154e@news.demon.nl>#1/1

That was sheer luck.
Add 'order by column_position' to your select on all_tab_columns.

Hth,

Sybrand Bakker, Oracle DBA

<jeanch_at_my-deja.com> wrote in message news:89osh9$o13$1_at_nnrp1.deja.com...
> Folks,
>
> Here is a good one right;
>
> I am building a string that contains like
> str := 'insert into tab select col1,col2,...,2,'tiger',coln
> from tab where id = 23';
>
> I obtain the column list for that table from all_tab_columns.
> SELECT COLUMN_NAME FROM ALL_TAB_COLUMNS
> WHERE TABLE_NAME = tab AND OWNER = 'scott';
>
> Up to now the order (given by the select to all_tab_columns) in which I
> was putting columns into the string
> was what oracle expected when I submit str;
>
> However for some reason it does not anymore.
>
> My question is how I can guarantie that the order in which I
> put columns and value in str will always be OK;
> Or where can I fetch the column list from a table and be sure that
> the order I am given will be fine for a insert into select type of
> transaction.
>
> Cheers
> JC
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Fri Mar 03 2000 - 00:00:00 CST

Original text of this message

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