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

Home -> Community -> Usenet -> c.d.o.misc -> Re: subselect and autonumber

Re: subselect and autonumber

From: Daniel Morgan <damorgan_at_x.washington.edu>
Date: Wed, 14 Jan 2004 02:52:26 -0800
Message-ID: <1074077470.593469@yasure>


rsj_at_gisportalen.dk wrote:

> Hi!
>
> I have an Oracle database insert problem! I have a table that I want
> to populate with records from another table. I use a subselect to do
> that, f.ex.:
>
> Insert into table 1 (col1, col2, col3) Select colA, colB, colC from
> table 2 where colA = xxx;
>
> This works fine! But now I want to have a column in table 1 with auto
> number. I have created a sequence seq1, and I imagine that the sql now
> should look like this:
>
> Insert into table 1 (auto1, col1, col2, col3) Values (seq1.nextval,
> (Select colA, colB, colC from table 2 where colA = xxx));
>
> But this does not work! Can anyone help me, perhaps with a "correct"
> sql?
>
> Regards
>
> RSJ
Insert into table 1 (auto1, col1, col2, col3) Values (Select SEQ1.NEXTVAL, colA, colB, colC from table 2 where colA = xxx));

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Wed Jan 14 2004 - 04:52:26 CST

Original text of this message

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