Link to home
Start Free TrialLog in
Avatar of abcexpert
abcexpert

asked on

ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at line 1

Hi,

I am calling an Oracle stored procedure from an ASP.Net application.

The Oracle Stored Procedure is:

----------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE simple_test (

   a_UserCode      IN varchar2,

   a_ErrorMsg      OUT varchar2) AUTHID CURRENT_USER

AS

BEGIN

 a_ErrorMsg  := a_UserCode || 'test' ;

END;
----------------------------------------------------------------------

This procedeure works fine when I run it in SQL Plus, but when I run it from ASP.Net I get the following error:

----------------------------------------------------------------------
ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at line 1
----------------------------------------------------------------------

The ASP.Net code is :

----------------------------------------------------------------------
        OleDbConnection1.Open()

        OleDbCommand1.CommandText = "simple_test"
        OleDbCommand1.CommandType = CommandType.StoredProcedure

        OleDbCommand1.Parameters.Add("a_UserCode", OracleType.VarChar)
        OleDbCommand1.Parameters("a_UserCode").Value = "TEST"

        OleDbCommand1.Parameters.Add("a_ErrorMsg", OracleType.VarChar)
        OleDbCommand1.Parameters("a_ErrorMsg").Direction = ParameterDirection.Output

        OleDbCommand1.ExecuteNonQuery()

        Label1.Text = OleDbCommand1.Parameters("a_ErrorMsg").Value

        OleDbConnection1.Close()
----------------------------------------------------------------------

Appreciate if anyone can help. I suspect the "OracleType.VarChar" as it should be VarChar2, but this is not availabe in ASP.Net and also you can't set the size of it from ASP.Net!
Avatar of kretzschmar
kretzschmar
Flag of Germany image

well, don't know the syntax, but i miss a maxlength-parameter like

OleDbCommand1.Parameters.Add("a_ErrorMsg", OracleType.VarChar, 4000)

meikl ;-)
Avatar of abcexpert
abcexpert

ASKER

When I add the size as you suggest in this way OleDbCommand1.Parameters.Add("a_ErrorMsg", OracleType.VarChar, 4000) I get the following error:

Specified argument was out of the range of valid values. Parameter name: Invalid OleDbType enumeration value: 22

Any Idea?
well, i have no docs, so i may give a sample value by mistake, which is out of a limited range

i found this on the web

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=357761&SiteID=1

this shows a value of 255

meikl ;-)
Meikl,

Even if I change the value to 255 I get the same error.

Anybody has another idea about the origenal request?
See this link: http://www.dotnet247.com/247reference/msgs/51/255394.aspx - maybe it will help You.
ASKER CERTIFIED SOLUTION
Avatar of GGuzdziol
GGuzdziol
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
GGuzdziol,

Thanks the OleDbType.VarChar works fine ...