当我运行我的程序时,我的捕获中出现此错误
ORA-06550:第1行,第7栏:
PLS-00905:对象DBI304134.FINDFREEBARCODE无效
ORA-06550:第1行,第7栏:
这是我使用的c#代码:
string freeBarcode = null;
try
{
string connection = ConfigurationManager.ConnectionStrings["P4connection"].ConnectionString;
using (OracleConnection con = new OracleConnection(connection))
{
OracleCommand cmd = new OracleCommand("FindfreeBarcode", con);
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter outpuparameter = new OracleParameter("outpuparameter", OracleDbType.Varchar2,100);
outpuparameter.ParameterName = "FREEBARCODE";
outpuparameter.Direction = ParameterDirection.Output;
cmd.Parameters.Add(outpuparameter);
con.Open();
cmd.ExecuteNonQuery();
freeBarcode = Convert.ToString(outpuparameter.Value.ToString());
if (freeBarcode == null)
{
freeBarcode = null;
}
else
{
freeBarcode = Convert.ToString(outpuparameter.Value.ToString());
}
}
}
catch
{
freeBarcode = null;
}
return freeBarcode;
这是我使用的存储过程:
create or replace procedure FindfreeBarcode
(FREEBARCODE out VARCHAR2)
is
begin
select b.BARCODE
INTO FREEBARCODE
from GAST g,BARCODECHECK b
WHERE g.GASTID(+) = b.GASTID and b.GASTID is null and ROWNUM <= 1;
END FindfreeBarcode;
答案 0 :(得分:0)
在此页面上找到我的答案
Stored procedure output parameter returns @Value
必须改变
freeBarcode = Convert.ToString(outpuparameter.Value.ToString());
为:
Convert.ToString(outpuparameter.Value);
答案 1 :(得分:0)
使用存储过程的原始版本,然后更改
OracleCommand cmd = new OracleCommand("FindfreeBarcode", con);
到
OracleCommand cmd = new OracleCommand("FindfreeBarcode(:FREEBARCODE)", con);
分享并享受。