我这个SQL为什么实现不了啊,不要管我的语法,这只是原型,
就是想用游标遍历基表,得到ITEM,然后在另外表中根据ITEM查找出PRICE,逻辑很简单,
估计问题出在:
"insert into 我的价格表(item,price)
select item,price from 价格表 where 价格表.item=item_v;"
但我不知道究竟是如何错的?
declare item_v varchar2(100);
mycursor cursor is select item from item基表;
open mycursor;
fetch my cursor into item_v;
while not %notfoud
insert into 我的价格表(item,price)
select item,price from 价格表 where 价格表.item=item_v;
commit;
loop;
end;
就是想用游标遍历基表,得到ITEM,然后在另外表中根据ITEM查找出PRICE,逻辑很简单,
估计问题出在:
"insert into 我的价格表(item,price)
select item,price from 价格表 where 价格表.item=item_v;"
但我不知道究竟是如何错的?
declare item_v varchar2(100);
mycursor cursor is select item from item基表;
open mycursor;
fetch my cursor into item_v;
while not %notfoud
insert into 我的价格表(item,price)
select item,price from 价格表 where 价格表.item=item_v;
commit;
loop;
end;
这种东西,如果你要返回结果集,就定义返回结果集的游标
item_v varchar2(100);
cursor mycursor is
select item from item基表;
begin
for rec in mycursor loop
item_v:=rec.item;
insert into 我的价格表(item,price)
select item,price from 价格表 where 价格表.item=item_v;
commit;
end loop;
end;
/
1、你的实际过程中可能有别的代码引起错误;
2、你的插入目标表有其他不允许为空的字段或有的字段有非法插入约束或外键约束;
仔细查一下吧,或者把全部代码贴上来