PLS-00306:调用'PUT_LINE'时参数的数量或类型错误

时间:2016-03-08 15:18:32

标签: oracle plsql oracle12c

这是我第一次尝试编写Oracle过程,并且在DBMS_OUTPUT.PUT_LINE行的中心出现错误(显示在问题标题中)。

我在线阅读它只能传回VARCAHR2列,因此我只会投出两个正在访问的非VARCHAR2列,但我仍然收到错误。当我尝试直接在oracle SQL Developer中运行它时,会发生此错误。

CREATE OR REPLACE PROCEDURE LOGGING_PRC 
(
  STARTDATE_IN IN VARCHAR2,
  ENDDATE_IN IN VARCHAR2,
  NAMES_IN IN VARCHAR2, 
  MODS_IN IN VARCHAR2, 
  LOGS_IN IN VARCHAR2,

  ID_OUT OUT VARCHAR2,
  NAME_OUT OUT VARCHAR2,
  MODULE_OUT OUT VARCHAR2,
  ENTRYDATE_OUT OUT VARCHAR2,
  STATUS_OUT OUT VARCHAR2,
  TYPE_OUT OUT VARCHAR2
)  
  AS 
BEGIN
    SELECT
    CAST(ID_LOG AS VARCHAR2(16)),
     APNAME,
     APPMOD,
     CAST(ENTRYDATE AS VARCHAR2(30)),
     APPSTATUS,
     LOGTYPE
  INTO 
      ID_OUT,
      NAME_OUT,
      MODULE_OUT,
      ENTRYDATE_OUT,
      STATUS_OUT,
      TYPE_OUT
   FROM 
     BASE          
   WHERE     
     ENTRYDATE > STARTDATE_IN AND
     ENTRYDATE  < ENDDATE_IN AND
     (NAMES  =  NAMES_IN OR NAMES_IN IS NULL) AND
     (MODS = MODS_IN OR MODS_IN IS NULL) AND
     (LOGS = LOGS_IN  OR LOGS_IN IS NULL);      
  RETURN;
DBMS_OUTPUT.PUT_LINE(ID_OUT, NAME_OUT, MODULE_OUT, ENTRYDATE_OUT, STATUS_OUT, TYPE_OUT);
END LOGGING_PRC;

有人看到我的代码不正确吗?

1 个答案:

答案 0 :(得分:7)

DBMS_OUTPUT.PUT_LINE定义如下

procedure put_line(a varchar2);

所以,它只接受一个输入参数。

如果您需要打印多个字段的值,则需要将它们连接在一个varchar2中;你可以试试:

DBMS_OUTPUT.PUT_LINE(ID_OUT || ',' || NAME_OUT || ',' || MODULE_OUT || ',' || ENTRYDATE_OUT || ',' || STATUS_OUT || ',' || TYPE_OUT);