i have a function in oracle with this signature
我在这个签名的oracle中有一个函数
test_fun(p_nat_no in number,p_number_type in number) RETURN test_table
in the c# this is the code
在c#这是代码
string select = "test_fun";
using (OracleConnection connection = new OracleConnection(helper.Global.ConnectionString))
{
OracleCommand command = new OracleCommand(select, connection);
// command.CommandType = CommandType.StoredProcedure;
OracleParameter PrmnatNo = new OracleParameter("p_nat_no ", natNo);//natNo
command.Parameters.Add(PrmnatNo);
OracleParameter pramNumberType = new OracleParameter("p_number_type ", numberType);
command.Parameters.Add(pramNumberType);
connection.Open();
using (OracleDataReader reader = command.ExecuteReader())
{
if (reader.HasRows)
{
List<test_table> Tickets = new List<test_table>();
while (reader.Read())
{
Tickets.Add(GetPropertyTaxHelper(reader));
}
return Tickets;
}
else return null;
}
}
Note: the function is work correctly from oracle.
注意:该功能在oracle中正常工作。
but when trying to call the function from c# an error appears (invalide sql statement) even the function is correct and returns output from oracle ? any help? suggestions?
但是当尝试从c#调用该函数时,出现错误(invalide sql语句),即使该函数是正确的并从oracle返回输出?任何帮助?建议?
1 个解决方案
#1
0
Your code doesn't work because you're using a reserved keyword (select
) as the name of the string, since the compiler think that this is a query expression, the code above won't work.
您的代码不起作用,因为您使用保留关键字(select)作为字符串的名称,因为编译器认为这是一个查询表达式,上面的代码将不起作用。
The fix is obviously easy, change the name of the string named "select".
修复显然很容易,更改名为“select”的字符串的名称。
#1
0
Your code doesn't work because you're using a reserved keyword (select
) as the name of the string, since the compiler think that this is a query expression, the code above won't work.
您的代码不起作用,因为您使用保留关键字(select)作为字符串的名称,因为编译器认为这是一个查询表达式,上面的代码将不起作用。
The fix is obviously easy, change the name of the string named "select".
修复显然很容易,更改名为“select”的字符串的名称。