Ask a Question related to Oracle Server, Design and Development.
-
Niloufar #1
multi-table insert in Oracle 9i
Could someone please tell me what am I doing wrong that causes both of
the following multi-table insert statements to fail with a "missing key"
error. My Oracle server is Version 9.2.0.2.0.
Thanks,
Niloufar
************************************************** *****************************
create table junk(id number,order_num varchar2(10),bill_amt number);
create table junk2(id2 number,order_num2 varchar2(10),bill_amt2 number);
create table junk_input(order_id number,order_number
varchar2(10),bill_amt number);
insert into junk_input values (1, '1234', 10);
insert into junk_input values (2, '1234', 10);
insert into junk_input values (3, '1234', 10);
insert into junk_input values (4, '5678', 10);
insert into junk_input values (5, '5678', 10);
select * from junk_input;
tried both:
insert all when 1=1
into junk (id, order_num, sequence_num)
select order_id, order_number, seq_num from junk_input;
and tried:
insert all when 1=1
into junk (id, order_num, sequence_num)
when order_number = '5678'
into junk2 (id2, order_num2, sequence_num2)
select order_id, order_number, seq_num from junk_input;
Niloufar Guest
-
#40787 [NEW]: Error trying to insert into a CLOB column when using multi-byte charset.
From: jarismar at adplabs dot com dot br Operating system: PHP version: 5.2.1 PHP Bug Type: PDO related Bug description: ... -
Oracle Table Access With Oracle OLEDB Driver
If I use the Oracle client to access the Oracle database with DW 2004, it does not display any tables. If I use the Microsoft client it does work. ... -
How Do you insert a table in Previous Table
How Do you insert a table in Previous Table that has an image, in a web page -
Login - multi table insert for registrant; subsquent login insert page requests into joined 'Selection' Table
Question regards insert and updates in sql server for a simple login script that requires registration the first time and only "email address" upon... -
How to insert multiple records to the same table with a multi-fields form
Hi all, is it possibile to insert multiple records in the same table? I imagine to build a multi-rows form, with the same number of fields per... -
Dave Hau #2
Re: multi-table insert in Oracle 9i
You're missing a "THEN" keyword:
insert all when 1=1 THEN
into junk (id, order_num, sequence_num) ...
Also, if the condition is 1=1, you don't need to specify it at all:
insert all
into junk (id, order_num, sequence_num) ...
does the same thing.
Cheers,
Dave
Niloufar wrote:> Could someone please tell me what am I doing wrong that causes both of
> the following multi-table insert statements to fail with a "missing key"
> error. My Oracle server is Version 9.2.0.2.0.
>
> Thanks,
> Niloufar
>
> ************************************************** *****************************
>
> create table junk(id number,order_num varchar2(10),bill_amt number);
> create table junk2(id2 number,order_num2 varchar2(10),bill_amt2 number);
> create table junk_input(order_id number,order_number
> varchar2(10),bill_amt number);
>
> insert into junk_input values (1, '1234', 10);
> insert into junk_input values (2, '1234', 10);
> insert into junk_input values (3, '1234', 10);
> insert into junk_input values (4, '5678', 10);
> insert into junk_input values (5, '5678', 10);
> select * from junk_input;
>
> tried both:
>
> insert all when 1=1
> into junk (id, order_num, sequence_num)
> select order_id, order_number, seq_num from junk_input;
>
> and tried:
>
> insert all when 1=1
> into junk (id, order_num, sequence_num)
> when order_number = '5678'
> into junk2 (id2, order_num2, sequence_num2)
> select order_id, order_number, seq_num from junk_input;
>
>Dave Hau Guest
-
Niloufar #3
Re: multi-table insert in Oracle 9i
Thank you Dave.
I feel silly that I didn't pay more attention to the syntax.
However, regarding the "when 1=1" clause, if I have multiple "when"
clauses in the statement, I can not execute it if the first "inert into"
doesn't have a when clause. I get a "missing select keyword" error.
Thanks,
Niloufar
Dave Hau wrote:> You're missing a "THEN" keyword:
>
> insert all when 1=1 THEN
> into junk (id, order_num, sequence_num) ...
>
> Also, if the condition is 1=1, you don't need to specify it at all:
>
> insert all
> into junk (id, order_num, sequence_num) ...
>
> does the same thing.
>
> Cheers,
> Dave
>
>
>
>
> Niloufar wrote:
>>>> Could someone please tell me what am I doing wrong that causes both of
>> the following multi-table insert statements to fail with a "missing
>> key" error. My Oracle server is Version 9.2.0.2.0.
>>
>> Thanks,
>> Niloufar
>>
>> ************************************************** *****************************
>>
>> create table junk(id number,order_num varchar2(10),bill_amt number);
>> create table junk2(id2 number,order_num2 varchar2(10),bill_amt2 number);
>> create table junk_input(order_id number,order_number
>> varchar2(10),bill_amt number);
>>
>> insert into junk_input values (1, '1234', 10);
>> insert into junk_input values (2, '1234', 10);
>> insert into junk_input values (3, '1234', 10);
>> insert into junk_input values (4, '5678', 10);
>> insert into junk_input values (5, '5678', 10);
>> select * from junk_input;
>>
>> tried both:
>>
>> insert all when 1=1
>> into junk (id, order_num, sequence_num)
>> select order_id, order_number, seq_num from junk_input;
>>
>> and tried:
>>
>> insert all when 1=1
>> into junk (id, order_num, sequence_num)
>> when order_number = '5678'
>> into junk2 (id2, order_num2, sequence_num2)
>> select order_id, order_number, seq_num from junk_input;
>>
>>Niloufar Guest
-
shonali #4
Re: multi-table insert in Oracle 9i
right answer is this
for single table
SQL> insert all when 1=1 then
2 into junk (id, order_num,bill_amt)
3 select order_id, order_number,bill_amt from junk_input;
for multitable
SQL> insert all when 1=1 then
2 into junk (id, order_num,bill_amt)
3 when order_number = '5678' then
4 into junk2 (id2, order_num2,bill_amt2)
5 select order_id, order_number,bill_amt from junk_input;shonali Guest



Reply With Quote

