我正在使用Oracle 10g
以下是我的包规范和主体:
CREATE OR REPLACE PACKAGE P_1 AS
TYPE T_CURSOR IS REF CURSOR;
PROCEDURE USP_1(SP_NUM OUT VARCHAR2);
END P_1;
CREATE OR REPLACE PACKAGE BODY P_1 AS
PROCEDURE USP_1(SP_NUM OUT VARCHAR2) IS
BEGIN
SELECT to_char(concat(to_char(sysdate, 'yyyymm'),
to_char("ActionId".nextval, '000')))
INTO SP_NUM FROM dual;
END USP_1;
END P_1;
我的后端代码是
using (OracleConnection oracleConnection = new BaseRepository().Connection)
{
oracleConnection.Open();
OracleCommand command = new OracleCommand("P_1.USP_1", oracleConnection);
command.CommandType = System.Data.CommandType.StoredProcedure;
command.Parameters.Add("SP_NUM", OracleDbType.Varchar2, 50,
System.Data.ParameterDirection.Output);
command.ExecuteNonQuery(); // exception arises at this line
var Number = Convert.ToInt32(command.Parameters["SP_REQ_NUM"].Value.ToString());
这是我得到的异常。
ORA-06502: PL/SQL: numeric or value error
我不知道我在哪里做错了什么。