我对使用游标有疑问。
Table t1 having "t1c1" and "t1c2" columns.
Table t2 having "t2c2" and "t2c2" columns.
Table t3 having "t3c2","t3c2","t3c3","t3c4" columns.
Two cursors "cur1" and "cur2".
我编写了代码,我需要使用for循环游标“cur1”
将值插入到t3中示例:
DECLARE
CURSOR cur1 IS
SELECT t1c1 FROM t1;
CURSOR cur2 IS
SELECT t2c1 FROM t2;
BEGIN
FOR f1 IN cur1 LOOP
EXIT WHEN cur1%NOTFOUND;
INSERT INTO TABLE t3
(
SELECT f1.t1c1,t2.t2c2,'hello' FROM t2;
);
END LOOP;
从上面的代码中我插入了表t3的前三列。
我想知道如何将cur2(光标值)插入表t3的第4列。
答案 0 :(得分:0)
insert into t3
select t1.t1c1, t2.t2c2, 'Hello'
from t1,
t2
对我来说真的很奇怪你没有提到t1和t3之间的任何联系,所以你得到了cartezian。