我在oracle中使用以下存储过程
PROCEDURE proc_test (
product_id IN Product_map.product_id%type,
external_product_id IN Product_map.ex_product_id%type,
product_seller OUT VARCHAR2,
product_name OUT VARCHAR2
) IS
BEGIN
SELECT seller, product_name
INTO product_seller, name
FROM product_map
WHERE product_id = product_id
AND ex_product_id = external_product_id;
END;
数据类型
product_id VARCHAR2(300 BYTE)
ex_product_id VARCHAR2(30 BYTE)
product_seller VARCHAR2(10 BYTE)
product_name VARCHAR2(400 BYTE)
执行存储过程和返回值的C#代码
using (OracleConnection objConn = new OracleConnection("Data Source=ORCL; User ID=scott; Password=tiger"))
{
OracleCommand objCmd = new OracleCommand();
objCmd.Connection = objConn;
objCmd.CommandText = "proc_test";
objCmd.CommandType = CommandType.StoredProcedure;
cmdBuilder.Parameters.Add("product_id", OracleDbType.Varchar2).Value = "a123";
cmdBuilder.Parameters.Add("external_product_id", OracleDbType.Varchar2).Value = "xyz123";
cmdBuilder.Parameters.Add("product_seller", OracleDbType.Varchar2).Direction = ParameterDirection.Output;
cmdBuilder.Parameters.Add("product_name", OracleDbType.Varchar2).Direction = ParameterDirection.Output;
try
{
objConn.Open();
objCmd.ExecuteNonQuery();
System.Console.WriteLine($"Product name is is {objCmd.Parameters["product_name"].Value}");
}
catch (Exception ex)
{
System.Console.WriteLine("Exception: {0}",ex.ToString());
}
objConn.Close();
}
我收到以下错误 -
ORA-06502:PL / SQL:数字或值错误\ nORA-06512。