我有以下Oracle過程(我已經採取了一些細節,並且使問題更加普遍:從INSERT返回多個值和插入兩到另一個表
create or replace
procedure Insert_Row (foo IN VARCHAR2,
buzz in VARCHAR2,
t_in MyType)
is
l_cur_id number;
begin
insert into table1 (foo,buzz)
returning bar into l_cur_id;
BEGIN
FOR i IN 1..t_in.count LOOP
insert into table2 (bar, something)
values(l_cur_id,t_in(i));
commit;
END LOOP;
end;
end;
它所做的就是插入一行到table1
,會從剛剛插入table1
該行的ID,並用它來插入table2
下面是我使用上述類型:
create or replace
TYPE MyType AS VARRAY(200) OF VARCHAR2(50);
我的問題:如何將buzz
插入table2
?即第二個值。我認爲一定很簡單,因爲我在插入之前已經有了buzz
的值。
非常感謝。
發佈後直接解決 - 典型!將發佈解決方案... – ale