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: Guido Konsolke <GK_at_oblivion.com>
Date: Wed, 14 Jan 2004 11:52:37 +0100
Message-ID: <1074076413.649795@news.thyssen.com>


<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
Hi RSJ (by the way, nice name ;-)),

without thinking to much: a 'before insert' trigger comes to mind.

hth,
Guido Received on Wed Jan 14 2004 - 04:52:37 CST

Original text of this message

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