当我尝试运行过程printshipment
时出现错误
PLS-00341: declaration of cursor 'C' is incomplete or malformed
我的游标声明有什么问题以及如何解决?
CREATE OR REPLACE PROCEDURE printshipment(onmbr IN shipment.onum%TYPE,
shnmbr IN shipment.snum%TYPE)
IS
CURSOR c IS
SELECT
shcontent.inum ino,
item.descr description,
item.qtyshipped q,
item.unitprice u,
u * q cost
FROM shcontent, item
WHERE shcontent.snum = shnmbr
AND shcontent.onum = onmbr
AND shcontent.inum = item.inum;
rec c%ROWTYPE;
BEGIN
OPEN c;
FETCH c INTO rec;
IF c%NOTFOUND THEN
dbms_output.put_line('No Shipment');
END IF;
CLOSE c;
END;
/
最佳答案
我认为,如果要在游标的查询中包含可变参数,则必须将其声明为参数化游标,如下所示:
CURSOR C (c_onmbr IN Shipment.onum%type, c_shnmbr IN Shipment.snum%type)
IS
SELECT ShContent.inum Ino, Item.descr description, Item.Qtyshipped Q,
Item.UnitPrice U, U * Q COST
FROM ShContent, Item
WHERE ShContent.snum = c_shnmbr
AND ShContent.onum = c_onmbr
AND ShContent.inum = Item.inum;
接着
OPEN C(onmbr, shnmbr);
不过,我可能会弄错。我的Oracle证书有点过时了。