I am trying to call an Oracle function which has a return type of number. I am calling from C# using OleDB and I understand that the mapping of type number in Oracle is a decimal. Whenever I call this i get a 0 back.
using (OleDbCommand _cmdDueAtDock = new OleDbCommand()) {
_cmdDueAtDock.Connection = connection;
_cmdDueAtDock.CommandType = CommandType.StoredProcedure;
_cmdDueAtDock.CommandText = "IFSAPP.PURCHASE_ORDER_LINE_API.GET_DUE_AT_DOCK";
_cmdDueAtDock.Parameters.Add(new OleDbParameter() {
ParameterName = "rv_",
OleDbType = OleDbType.Decimal,
Direction = ParameterDirection.ReturnValue
});
_cmdDueAtDock.Parameters.Add(new OleDbParameter() {
ParameterName = "order_no_",
OleDbType = OleDbType.VarChar,
Size = 50,
Direction = ParameterDirection.Input,
Value = _order_line.ORDER_NO
});
_cmdDueAtDock.Parameters.Add(new OleDbParameter() {
ParameterName = "line_no_",
OleDbType = OleDbType.VarChar,
Size = 50,
Direction = ParameterDirection.Input,
Value = _order_line.LINE_NO
});
_cmdDueAtDock.Parameters.Add(new OleDbParameter() {
ParameterName = "release_no_",
OleDbType = OleDbType.VarChar,
Size = 50,
Direction = ParameterDirection.Input,
Value = _order_line.RELEASE_NO
});
try {
_cmdDueAtDock.ExecuteNonQuery();
dueAtDock = Convert.ToDecimal(_cmdDueAtDock.Parameters["rv_"].Value);
} catch (Exception ex) {
dueAtDock = 0;
}
}
I am using Oracle client 11.2.0
and the oracle database version is 10.2.0.4.0
.
I have read about the 11.1 client having issues, i was actually able to sumulate the behaviour with the 11.1 client by select to_char(function) from dual
- I get a correct result without the to_char
but a 0
with to_char
. Upgrading my client to 11.2 resolve this issue locally.