插入父表ID的子表记录

时间:2012-12-06 13:00:17

标签: sql oracle sql-server-2008 oracle10g oracle11g

我有两个表父表和子表。我想同时插入父表和子表记录。但是具有父ID的子表。抱歉我的英文。

Table 1
=======
fld_id name desc
 1     sasi new_customer
 2     arun old_customer


Table 2
=======
fld_id fld_parent_id  product
 1       1             Dress
 2       1             watch
 3       1             phone
 4       2             Clock
 5       2             pen

My input value like this
========================

1,sasi ,Dress|watch|phone
2,Arun ,Clock|pen

请帮我这样做..

1 个答案:

答案 0 :(得分:0)

begin

insert into parent_table;  --insert statement for parent table
insert into child table ;  --insert statement for child table

commit;
end;