Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-06502 PL/SQL: numeric or value error ORA-06512 when calling a procedure

709425Jun 29 2009 — edited Jul 3 2009
Hi,
I have been using ODP.net for a while now and have been calling lots of procedures without issue, however today I put together one to insert key, value parameters into a simple table and it is failing on me Intermittently with the ORA-06502... I have checked the code and I do not see any problems and am thoroughly frustrated... When I call the procedure directly it all works perfectly so the problem is not in the db!

Please can you help? Code follows:

Table defined as:

CREATE TABLE REPORT_REQUEST_PARAMETERS
( REQUEST_ID NUMBER,
PARAM_NAME VARCHAR2(50 BYTE),
PARAM_VALUE VARCHAR2(255 BYTE)
)

Stored procedure defined as:

create or replace PROCEDURE SP_WRITE_REQUEST_PARAMS
( in_request_id number, in_param_name char, in_param_value char )
AS
BEGIN
INSERT INTO REPORT_REQUEST_PARAMETERS ( REQUEST_ID, PARAM_NAME, PARAM_VALUE )
VALUES
( in_request_id, in_param_name, in_param_value );
END SP_WRITE_REQUEST_PARAMS;

Finally the ODP.net code which calls this looks like:

using (OracleConnection connection = new OracleConnection(...blah...))
{
using (OracleCommand command = connection.CreateCommand())
{
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "SP_WRITE_REQUEST_PARAMS";

OracleParameter p1 = new OracleParameter("in_request_id", OracleDbType.Int32);
OracleParameter p2 = new OracleParameter("in_param_name", OracleDbType.Char);
OracleParameter p3 = new OracleParameter("in_param_value", OracleDbType.Char);

p1.Direction = ParameterDirection.Input;
p1.Value = requestId;

p2.Direction = ParameterDirection.Input;
p2.Size = paramName.Length;
p2.Value = paramName;

p3.Direction = ParameterDirection.Input;
p3.Size = paramValue.Length;
p3.Value = paramValue;

command.Parameters.Add(p1);
command.Parameters.Add(p2);
command.Parameters.Add(p3);

connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 31 2009
Added on Jun 29 2009
3 comments
2,056 views