oracle PLS-00306:调用“PUT_LINE”时参数数量或类型错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35871212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
提问by michaelk46
This is the first time I have tried writing an Oracle procedure and I am getting an error (shown in the question title) centering on the DBMS_OUTPUT.PUT_LINE
line.
这是我第一次尝试编写 Oracle 过程,但出现以行为中心的错误(显示在问题标题中)DBMS_OUTPUT.PUT_LINE
。
I read online that it can only hand back VARCAHR2
columns, so I have cast the only two non VARCHAR2
columns that are being accessed, but I am still getting the error. This error is happening when I try to run it directly in the oracle SQL Developer.
我在网上读到它只能交回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;
Does someone see where I have the incorrect code?
有人看到我哪里有错误的代码吗?
回答by Aleksej
DBMS_OUTPUT.PUT_LINE is defined as follows
DBMS_OUTPUT.PUT_LINE 定义如下
procedure put_line(a varchar2);
so, it only accepts one input parameter.
所以,它只接受一个输入参数。
If you need to print the values of more than one field, you need to concatenate them in a single varchar2
; you can try with :
如果需要打印多个字段的值,则需要将它们连接在一个varchar2
; 你可以尝试:
DBMS_OUTPUT.PUT_LINE(ID_OUT || ',' || NAME_OUT || ',' || MODULE_OUT || ',' || ENTRYDATE_OUT || ',' || STATUS_OUT || ',' || TYPE_OUT);