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: Compound INSERT statement - easy (I think)

Re: Compound INSERT statement - easy (I think)

From: Peter H. Larsen <plarsen.nospam_at_dc.dynares.com>
Date: Thu, 09 Jul 1998 08:40:42 -0400
Message-ID: <35A4BA4A.3B3044D4@dc.dynares.com>


Hi Sean,
You got a small syntax error ...
First of all, I think you want to insert the SAME value from the sequence from all selected rows? Well, that won't work unless you use a bind variable to do that ... anyway, the syntax you're looking for is this:

INSERT INTO <table> (column, column .....) SELECT expr, expr ....
FROM
....

There is NO VALUES specifier ... Using VALUES you only insert ONE row, and that's not from a select. You can select the sequence.nextval as an expression. But it will give you different values for eacy new record .... which I find a very powerful feature.

Sean Dolan wrote:
>
> All I am trying to do is insert a new record into a table using the data from another table. The query is below but won;t work... can someone help, please.
>
> insert into knowledge(id, product_id, short_prob, long_prob,
> short_solu, long_solu, steps) values(knowledge_seq.nextval, (
> select ik.product_id, ik.short_prob, ik.long_prob, ik.short_solu,
> ik.long_solu, ik.steps from shhd_owner.inc_to_knowledge ik where
> ik.id=24));
>
> Thanks,
> Sean

--

Peter H. Larsen, Oracle and Applications specialist Dynamic Resources Inc, Alexandria
Email: plarsen_at_dc.dynares.com
(please remove the nospam from the header when replying to this email)

The above views are my own and does not reflect the views of my employer. Received on Thu Jul 09 1998 - 07:40:42 CDT

Original text of this message

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