[英]How to run function that in packages in oracle (c#)
I need to call to some function and procedures that in packages in Oracle. 我需要调用Oracle软件包中的某些函数和过程。 I never worked with oracle, and i know only basic staff like insert,update table, but now i need to call "vb_new_serial " function to get back from it integer here this function function vb_new_serial return integer;
我从来没有使用过oracle,我只知道基本的人员,例如insert,update表,但是现在我需要调用“ vb_new_serial”函数以从中获取整数,这里该function vb_new_serial return integer;
This function is located in Packages VN_PKG -> vb_new_serial 此功能位于软件包VN_PKG- > vb_new_serial中
Here my code that i tried after i did some reasearches: 这是我进行一些重新搜索后尝试的代码:
using (var conn = new OracleConnection(strConn2))
{
using (var cmd = conn.CreateCommand())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "vb_new_serial";
conn.Open();
using (var dr = cmd.ExecuteReader())
{
MessageBox.Show(dr.ToString());
}
}
}
Here the image 这是图片
But here i did't get back nothing. 但是在这里我什么也没回来。
What i am doing wrong? 我做错了什么?
Is there any parameters need to add in oracle command ? 在oracle命令中是否需要添加任何参数? because return value is the first parameter added to the oracle command. 因为返回值是添加到oracle命令的第一个参数。
Like this 像这样
cmd.Parameters.Add("Return_Value", OracleDbType.Int16,
ParameterDirection.ReturnValue);
You just need to change your code in order to get the integer that the Oracle function returns: 您只需要更改代码即可获取Oracle函数返回的整数:
using (var conn = new OracleConnection(strConn2))
{
using (var cmd = conn.CreateCommand())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "VN_PKG.vb_new_serial";
OracleParameter myReturn = new OracleParameter("myReturn", OracleDbType.Int32, ParameterDirection.ReturnValue);
cmd.Parameters.Add(myReturn);
conn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show(myReturn.Value.ToString());
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.