how can I out a parameter as varchar2 in oracle
There are no less than 10 overloads of the OracleParameterCollection.Add
method. It looks like you have accidentally called the wrong one.
I believe the one you want is Add(string, OracleDbType, int, object, ParameterDirection)
, in which case you're just missing a value for the object
parameter. This parameter should contain an initial value for the Oracle parameter you're using. In your case, however, the initial value doesn't matter as it's an out
parameter. Add null
after 50
and your stored procedure call should succeed.
The one you have called is Add(string, OracleDbType, object, ParameterDirection)
. The size 50
has been interpreted as an initial value for the parameter. I'm not sure how to interpret the error that Oracle returns ("numeric or value error") – that implies to me that Oracle has tried to convert a string to a number and failed. Perhaps the value 50
overrides the type OracleDbType.Varchar2
and so Oracle expects a number rather than a string?
There were another couple of problems I found:
- Should
command.Parameters["SP_REQ_NUM"]
becommand.Parameters["SP_NUM"]
? - Your stored procedure doesn't return a number; calling
Convert.ToInt32
on a string such as201405 001
will fail.