NET存储过程返回的Oracle输出参数

NET存储过程返回的Oracle输出参数

本文介绍了如何从.NET存储过程返回的Oracle输出参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有试图让数据从SP背面的严重问题。我试图做这样的:

I am having serious issues trying to get the data back from the SP. I was trying to do it like this:

OracleCommand ora_cmd = new OracleCommand("a6r1.PR_ABC_P_ALTA_TARJETA_PAYWARE", ora_conn);
                    ora_cmd.BindByName = true;
                    ora_cmd.CommandType = CommandType.StoredProcedure;

                    int success= new int();

                    ora_cmd.Parameters.Add("Lc_Param_Issuer", OracleDbType.Varchar2, issuer, ParameterDirection.Input);
                    ora_cmd.Parameters.Add("Ln_Param_Valid_Product", OracleDbType.Varchar2, DropDownListProducto.SelectedValue.ToString(), ParameterDirection.Input);
                    ora_cmd.Parameters.Add("Ln_Param_Total", OracleDbType.Int32, parsed, ParameterDirection.Input);
                    ora_cmd.Parameters.Add("Lc_Param_User", OracleDbType.Varchar2, user, ParameterDirection.Input);
                    ora_cmd.Parameters.Add("Lc_Encrypted_Password", OracleDbType.Varchar2, pass, ParameterDirection.Input);
                    ora_cmd.Parameters.Add("Lc_Exito", OracleDbType.Int32, success, ParameterDirection.Output);
                    ora_cmd.Parameters.Add("Lc_Error", OracleDbType.Varchar2, errorMessage, ParameterDirection.Output);

但它没有返回任何变量sucess或的errorMessage。我究竟做错了什么?有没有更好的办法?当甲骨文直接执行它工作正常。

But it is not returning anything to the variables sucess or errorMessage. What am I doing wrong? Is there a better way? It works fine when executed directly on Oracle.

推荐答案

看来你不能用现有的变量作为输出参数,试试这种方式,而不是

It seems you cannot use existing variable as output parameter, try this way instead

ora_cmd.Parameters.Add("Lc_Exito", OracleDbType.Int32).Direction = ParameterDirection.Output;

ora_cmd.ExecuteNonQuery();

if (ora_cmd.Parameters["Lc_Exito"].value == 0)

这篇关于如何从.NET存储过程返回的Oracle输出参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 18:25