1

我有一个表,我想从中获得下一个最低优先级的 DVDid,把它作为输出给我,然后从表中删除它。我通过创建一个包来做到这一点......代码被编译但是当我执行它时给我错误。有什么建议吗?

table:
RENTALQUEUE (MEMBERID, DVDID, DATEADDEDINQUEUE, PRIORITY)

这是包:

create or replace
PACKAGE  pk_GET_TITLEID AS
procedure sp_GET_TITLEID(memberid_arg IN NUMBER,
titleid_arg out number) ;
end pk_GET_TITLEID;

create or replace
package body pk_GET_TITLEID as 
procedure sp_GET_TITLEID 
(memberid_arg IN NUMBER,
titleid_arg out number)

IS 
v_priority number;
begin

SELECT  MIN(PRIORITY)into v_priority
FROM RENTALQUEUE 
WHERE memberid = memberid_arg;

DBMS_OUTPUT.PUT_LINE (titleid_arg);

DELETE FROM RENTALQUEUE 
WHERE MEMBERID=memberid_arg AND dvdid=titleid_arg;

END sp_GET_TITLEID;
END PK_GET_TITLEID;

我是这样称呼它的:

execute pk_get_titleid.sp_get_titleid('1');

这是错误:

Error:
    Error starting at line 403 in command:
    execute pk_get_titleid.sp_get_titleid('1')
    Error report:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'SP_GET_TITLEID'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
4

1 回答 1

3

错误是:

PLS-00306: wrong number or types of arguments in call to 'SP_GET_TITLEID' 

您的过程在其签名中有多少个参数?

procedure sp_GET_TITLEID 
    (memberid_arg IN NUMBER
    ,   titleid_arg out number)  

二。你传递了多少参数?

执行 pk_get_titleid.sp_get_titleid('1')

一。

out 参数仍然是参数。您需要将其包含在通话中。具体来说,您需要调用环境中的一个变量,该变量可以接收来自被调用过程的答案。您的代码实际上并未填充titleid_arg参数这一事实不会影响这一点。


参数的非填充titleid_arg只是突出了代码中的混乱。也许它应该是一个 IN 参数?也许您需要从另一个表中选择它?有什么意义v_priority

于 2012-09-25T13:02:50.930 回答