调用中的参数数量或类型错误
Posted
技术标签:
【中文标题】调用中的参数数量或类型错误【英文标题】:wrong number or types of arguments in call 【发布时间】:2021-07-15 08:30:50 【问题描述】:我认为输出参数代码有问题。但我不知道如何解决这个问题。谁能告诉我我的代码有什么问题?
错误:
ORA-06550:第 1 行,第 7 列:PLS-00306:调用“SP_WF_GET_REQUESTDETAILS”时参数的数量或类型错误 ORA-06550:第 1 行,第 7 列:PL/SQL:语句被忽略
我的代码
public DataResponse<DataTable> GetRequestCount(string Usercode)
try
var paramList = new List<OracleParameter>();
paramList.Add(new OracleParameter("P_IN_KEY", "GET_REQUEST_COUNT"));
paramList.Add(new OracleParameter("P_USER_CODE", Usercode));
OracleParameter param = new OracleParameter("P_OUT_OPEN", OracleType.Cursor);
OracleParameter param1 = new OracleParameter("P_OUT_APPROVED", OracleType.Cursor);
OracleParameter param2 = new OracleParameter("P_OUT_REJECTED", OracleType.Cursor);
param.Direction = ParameterDirection.Output;
param1.Direction = ParameterDirection.Output;
param2.Direction = ParameterDirection.Output;
paramList.Add(param);
paramList.Add(param1);
paramList.Add(param2);
var data = SPExcute("SP_WF_GET_REQUESTDETAILS", paramList);
return data;
catch (Exception ex)
ex.LogInfo();
return new DataResponse<DataTable>(DataResponseCode.InvaildInputs);
我的存储过程
create or replace PROCEDURE SP_WF_GET_REQUESTDETAILS (P_IN_KEY IN VARCHAR2,
P_USER_CODE varchar2,
P_OUT_OPEN OUT SYS_REFCURSOR,
P_OUT_APPROVED OUT SYS_REFCURSOR,
P_OUT_REJECTED OUT SYS_REFCURSOR,
P_OUT_TBL OUT SYS_REFCURSOR) AS
BEGIN
IF P_IN_KEY='GET_OPENREQUEST' THEN
BEGIN
OPEN P_OUT_TBL FOR
SELECT A.REQUEST_NO AS Request_No,
A.REQUEST_DATE AS Request_Date,
A.CATEGORY_CODE AS Category_Code,
A.STATUS AS Status
FROM WF_TBL_TRN_REQUEST_HEADER A
WHERE A.CREATED_BY=P_USER_CODE AND (A.STATUS='OPEN' OR A.STATUS like 'APPROVE LEVEL%');
END;
ELSIF P_IN_KEY='GET_APROVEDREQUEST' THEN
BEGIN
OPEN P_OUT_TBL FOR
SELECT A.REQUEST_NO AS Request_No,
A.REQUEST_DATE AS Request_Date,
A.CATEGORY_CODE AS Category_Code,
A.STATUS AS Status
FROM WF_TBL_TRN_REQUEST_HEADER A
WHERE A.CREATED_BY=P_USER_CODE AND (A.STATUS='APPROVED');
END;
ELSIF P_IN_KEY='GET_REJECTEDREQUEST' THEN
BEGIN
OPEN P_OUT_TBL FOR
SELECT A.REQUEST_NO AS Request_No,
A.REQUEST_DATE AS Request_Date,
A.CATEGORY_CODE AS Category_Code,
A.STATUS AS Status
FROM WF_TBL_TRN_REQUEST_HEADER A
WHERE A.CREATED_BY=P_USER_CODE AND (A.STATUS='REJECTED' OR A.STATUS like 'REJECTED LEVEL%');
END;
ELSIF P_IN_KEY='GET_REQUEST_COUNT' THEN
BEGIN
OPEN P_OUT_OPEN FOR
SELECT COUNT(*) Open_Request_Count FROM WF_TBL_TRN_REQUEST_HEADER A WHERE A.CREATED_BY=P_USER_CODE AND (A.STATUS='OPEN' OR A.STATUS like 'APPROVE LEVEL%');
END;
BEGIN
OPEN P_OUT_APPROVED FOR
SELECT COUNT(*) Approved_Request_Count FROM WF_TBL_TRN_REQUEST_HEADER A WHERE A.CREATED_BY=P_USER_CODE AND (A.STATUS='APPROVED');
END;
BEGIN
OPEN P_OUT_REJECTED FOR
SELECT COUNT(*) Rejected_Request_Count FROM WF_TBL_TRN_REQUEST_HEADER A WHERE A.CREATED_BY=P_USER_CODE AND (A.STATUS='REJECTED' OR A.STATUS like 'REJECTED LEVEL%');
END;
END IF;
END SP_WF_GET_REQUESTDETAILS;
这是我完整的存储过程
【问题讨论】:
看来你调用的是5个参数的存储过程,请确保存储过程实际上是5个参数。 你的存储过程代码不完整 其实这里我已经添加了部分程序。现在我已经添加了整个存储过程 您似乎错过了 c# 代码中的P_OUT_TBL
参数
这并不意味着你可以在调用存储过程时从参数列表中省略它。
【参考方案1】:
您的 SP 第 2 行不应该从“P_USER_CODE varchar2”更改为“P_USER_CODE IN varchar2”吗?
【讨论】:
是的,我错过了。但在此之后我也得到了同样的错误 ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'SP_WF_GET_REQUESTDETAILS' ORA-06550: line 1, column 7: PL/SQL: Statement忽略以上是关于调用中的参数数量或类型错误的主要内容,如果未能解决你的问题,请参考以下文章
ORA-06550:PLS-00306: 调用中的参数数量或类型错误;ORA-06550:
从 C# 执行 Oracle 存储过程 - 调用中的参数数量或类型错误
PLS-00306:调用 'GET_LINE' 时参数的数量或类型错误。在 PL/SQL 中的函数中传递字符串参数时出现此错误