我在 Oracle 10g 数据库中名为 TEST 的 Oracle 包中有一个函数
FUNCTION GetEname(P_ename IN VARCHAR2) RETURN VARCHAR2 AS
retVal VARCHAR2(10);
BEGIN
retVal := SUBSTR(P_ename, 3, INSTR(P_ename, ':', 1, 2) - 3);
RETURN RetVal;
END GetEntDefIEIDFromEname;
我创建了一个 ASP.net 页面,并且在 page_load 中有以下代码:
String strResult = "";
try
{
oracleConn.ConnectionString = ConfigurationManager.ConnectionStrings["OracleDatabase"].ConnectionString;
oracleConn.Open();
OracleCommand orclCmnd = new OracleCommand();
orclCmnd.Connection = oracleConn;
orclCmnd.CommandText = "TEST.GetEname";
orclCmnd.CommandType = CommandType.StoredProcedure;
OracleParameter ename = new OracleParameter();
ename.ParameterName = "ename";
ename.OracleType = OracleType.VarChar;
ename.Direction = ParameterDirection.Input;
ename.Value = "0:490330";
orclCmnd.Parameters.Add(ename);
strResult = (String)orclCmnd.ExecuteOracleScalar();
oracleConn.Close();
oracleConn.Dispose();
lbl1.Text = "Result of " + strResult;
}
catch (Exception ex)
{
Console.Out.WriteLine(ex.ToString());
oracleConn.Close();
}
当我运行代码时,我收到以下错误消息:
"ORA-06550:第 1 行,第 7 列:\nPLS-00306:调用 'GETENAME' 时参数的数量或类型错误\nORA-06550:第 1 行,第 7 列:\nPL/SQL:语句被忽略\n"} System.Exception {System.Data.OracleClient.OracleException}