C# 获取 oracle 存储过程的 返回值

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C# 获取 oracle 存储过程的 返回值相关的知识,希望对你有一定的参考价值。

存储过程
CREATE OR REPLACE PROCEDURE ADMIN.INSERT_OBJ (
   OBJEFIRT_parms      IN     NVARCHAR2,
   OBJEDATT_parms      IN     NVARCHAR2,
   OBJESECT_parms      IN     NVARCHAR2,
   OBJECONTENT_parms   IN     NVARCHAR2,
   ISRELEASE_parms     IN     INTEGER,
   OBJECODE_parms      IN     NVARCHAR2,
   TAGS_parms          IN     NVARCHAR2,
   OBJ_ID_parms           OUT INTEGER
)
IS
BEGIN
   INSERT INTO ADMIN.CB_OBJECT (OBJEID,
                                OBJEFIRT,
                                OBJEDATT,
                                OBJESECT,
                                OBJECONTENT,
                                ISRELEASE,
                                OBJECODE,
                                TAGS)
     VALUES   (ADMIN.CYANBIRD.NEXTVAL,
               OBJEFIRT_parms,
               TO_DATE (OBJEDATT_parms, YYYY-MM-DD hh24:mi:ss),
               OBJESECT_parms,
               OBJECONTENT_parms,
               ISRELEASE_parms,
               OBJECODE_parms,
               TAGS_parms)
     RETURN   OBJEID     INTO   OBJ_ID_parms;

   RETURN;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      NULL;
   WHEN OTHERS
   THEN
      -- Consider logging the error and then re-raise
      RAISE;
END INSERT_OBJ;
C#中获取值

                DbParameter[] paras = new OracleParameter[8];
                paras[0] = new OracleParameter("OBJEFIRT_parms", OracleType.NVarChar);
                paras[0].Value = cbinf.ObjeFirT;
                paras[1] = new OracleParameter("OBJEDATT_parms", OracleType.NVarChar);
                paras[1].Value=cbinf.ObjeDatT.ToString();
                paras[2]= new OracleParameter("OBJESECT_parms",OracleType.NVarChar);
                paras[2].Value = cbinf.ObjeSecT;
                paras[3] = new OracleParameter("OBJECONTENT_parms", OracleType.NVarChar);
                paras[3].Value = cbinf.ObjeContent;
                paras[4] = new OracleParameter("ISRELEASE_parms", OracleType.Int32);
                paras[4].Value = cbinf.IsRelease;
                paras[5] = new OracleParameter("OBJECODE_parms", OracleType.NVarChar);
                paras[5].Value = cbinf.ObjeCode;
                paras[6] = new OracleParameter("TAGS_parms", OracleType.NVarChar);
                paras[6].Value = cbinf.Tags;
                paras[7] = new OracleParameter("OBJ_ID_parms", OracleType.Int32);
                paras[7].Direction = ParameterDirection.Output;
                SQLHelper.ExecuteScaler(InsertInfo_Obj, CommandType.StoredProcedure, paras);
                int i=Convert.ToInt32(paras[7].Value);
                return i;



以上是关于C# 获取 oracle 存储过程的 返回值的主要内容,如果未能解决你的问题,请参考以下文章

C#获取存储过程的 Return返回值和Output输出参数值

java中如何获取oracle存储过程返回的多个值。

执行sql操作后如何获取其返回值

Asp.net(C#) 获取 执行sql server 语句/存储过程后的 多个返回值?

C# 存储过程 如何返回 tatatable

sqlalchemy 调用 mssql存储过程如何获取返回值?