Solved

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

Posted on 2006-11-08
7
3,380 Views
Last Modified: 2013-12-12
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!
0
Comment
Question by:abcexpert
  • 3
  • 2
  • 2
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 17904772
well, don't know the syntax, but i miss a maxlength-parameter like

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

meikl ;-)
0
 

Author Comment

by:abcexpert
ID: 17904871
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?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 17904940
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 ;-)
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:abcexpert
ID: 17904983
Meikl,

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

Anybody has another idea about the origenal request?
0
 
LVL 14

Expert Comment

by:GGuzdziol
ID: 17905597
See this link: http://www.dotnet247.com/247reference/msgs/51/255394.aspx - maybe it will help You.
0
 
LVL 14

Accepted Solution

by:
GGuzdziol earned 500 total points
ID: 17905603
I mean: probably You should use OleDbType.VarChar instead of OracleType.VarChar
0
 

Author Comment

by:abcexpert
ID: 17905916
GGuzdziol,

Thanks the OleDbType.VarChar works fine ...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and theā€¦
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question