CREATE OR REPLACE PROCEDURE GET_SINGLE_CUSTOMERINFO(
P_ID IN NUMBER,
P_AGE OUT NUMBER,
P_OCCUPATION OUT VARCHAR2,
P_LASTSTATEMENT OUT VARCHAR2
) AS
BEGIN
SELECT AGE,
OCCUPATION,
LASTSTATEMENT
INTO P_AGE,
P_OCCUPATION,
P_LASTSTATEMENT
FROM crossallcustomers
WHERE crossallcustomers.id = P_ID;
END;
修改
SET SERVEROUTPUT ON;
SQL> VARIABLE P_ID NUMBER;
SQL> EXEC GET_SINGLE_CUSTOMERINFO(123,:P_ID);
第1行的错误:ORA-06550:第1行第7列:PLS-00306:错误的数字 或调用' GET_SINGLE_CUSTOMERINFO' ORA-06550: 第1行,第7行:PL / SQL:忽略语句*
答案 0 :(得分:3)
您通过仅传递两个参数来调用具有四个参数的过程,没有默认值。
这是如何调用您的程序的示例:
declare
V_AGE NUMBER;
V_OCCUPATION VARCHAR2(10);
V_LASTSTATEMENT VARCHAR2(10);
begin
GET_SINGLE_CUSTOMERINFO (
P_ID => 1 ,
P_AGE => V_AGE ,
P_OCCUPATION => V_OCCUPATION ,
P_LASTSTATEMENT => V_LASTSTATEMENT
);
end;
或,带变量:
SQL> variable V_AGE number;
SQL> variable V_OCCUPATION varchar2(10);
SQL> variable V_LASTSTATEMENT varchar2(10);
SQL> exec GET_SINGLE_CUSTOMERINFO (P_ID => 1, P_AGE => :V_AGE, P_OCCUPATION => :V_OCCUPATION , P_LASTSTATEMENT => :V_LASTSTATEMENT );
PL/SQL procedure successfully completed.