473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Trouble executing a stored procedure

Hello:

I wrote a test procedure on Oracle that returns a string and a value.

CREATE OR REPLACE PROCEDURE EBMS.p_CSV_Upload
(
P_ERROR OUT VARCHAR2,
P_ERROR_NO OUT Number
)
AS

BEGIN
P_ERROR := 'Test Successful';
P_ERROR_NO := '1';
END;

I then tried to execute the SP from VB.Net. Here's the code snippet:

Dim queryString As String = "p_CSV_Upload"

Using connection As New OracleConnection(myConnectionString)
Dim command As New OracleCommand(queryString)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("P_ERROR", OracleType.VarChar).Direction
= ParameterDirection.Output
command.Parameters.Add("P_ERROR_NO", OracleType.Int32).Direction
= ParameterDirection.Output
command.Connection = connection
Try
connection.Open()
Dim reader As OracleDataReader = command.ExecuteReader()
MsgBox((reader.GetString(0)))
MsgBox((reader.GetInt32(1)))

Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Using

When I execute, the line, "Dim reader As OracleDataReader =
command.ExecuteReader()" raises an exception, "{"Parameter 'P_ERROR': No size
set for variable length data type: String."}

What am I doing wrong?

Oct 11 '06 #1
2 2301
Hello:

I solved it partially. I added the length of the string to the parameter:

command.Parameters.Add("P_ERROR", OracleType.VarChar,
100).Direction = ParameterDirection.Output

I also changed the syntax using DataReader:

Try
connection.Open()

Dim reader As OracleDataReader = command.ExecuteReader
MsgBox((reader.GetString(0)))
MsgBox((reader.GetInt32(1)))

Catch ex As Exception
Console.WriteLine(ex.Message)
End Try

But the line, MsgBox, throws an exception, " {"No data exists for the row or
column."}

Any idea?

venki

"vvenk" wrote:
Hello:

I wrote a test procedure on Oracle that returns a string and a value.

CREATE OR REPLACE PROCEDURE EBMS.p_CSV_Upload
(
P_ERROR OUT VARCHAR2,
P_ERROR_NO OUT Number
)
AS

BEGIN
P_ERROR := 'Test Successful';
P_ERROR_NO := '1';
END;

I then tried to execute the SP from VB.Net. Here's the code snippet:

Dim queryString As String = "p_CSV_Upload"

Using connection As New OracleConnection(myConnectionString)
Dim command As New OracleCommand(queryString)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("P_ERROR", OracleType.VarChar).Direction
= ParameterDirection.Output
command.Parameters.Add("P_ERROR_NO", OracleType.Int32).Direction
= ParameterDirection.Output
command.Connection = connection
Try
connection.Open()
Dim reader As OracleDataReader = command.ExecuteReader()
MsgBox((reader.GetString(0)))
MsgBox((reader.GetInt32(1)))

Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Using

When I execute, the line, "Dim reader As OracleDataReader =
command.ExecuteReader()" raises an exception, "{"Parameter 'P_ERROR': No size
set for variable length data type: String."}

What am I doing wrong?
Oct 11 '06 #2
vvenk,

reader.Read

Kerry Moorman
"vvenk" wrote:
Hello:

I solved it partially. I added the length of the string to the parameter:

command.Parameters.Add("P_ERROR", OracleType.VarChar,
100).Direction = ParameterDirection.Output

I also changed the syntax using DataReader:

Try
connection.Open()

Dim reader As OracleDataReader = command.ExecuteReader
MsgBox((reader.GetString(0)))
MsgBox((reader.GetInt32(1)))

Catch ex As Exception
Console.WriteLine(ex.Message)
End Try

But the line, MsgBox, throws an exception, " {"No data exists for the row or
column."}

Any idea?

venki

"vvenk" wrote:
Hello:

I wrote a test procedure on Oracle that returns a string and a value.

CREATE OR REPLACE PROCEDURE EBMS.p_CSV_Upload
(
P_ERROR OUT VARCHAR2,
P_ERROR_NO OUT Number
)
AS

BEGIN
P_ERROR := 'Test Successful';
P_ERROR_NO := '1';
END;

I then tried to execute the SP from VB.Net. Here's the code snippet:

Dim queryString As String = "p_CSV_Upload"

Using connection As New OracleConnection(myConnectionString)
Dim command As New OracleCommand(queryString)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("P_ERROR", OracleType.VarChar).Direction
= ParameterDirection.Output
command.Parameters.Add("P_ERROR_NO", OracleType.Int32).Direction
= ParameterDirection.Output
command.Connection = connection
Try
connection.Open()
Dim reader As OracleDataReader = command.ExecuteReader()
MsgBox((reader.GetString(0)))
MsgBox((reader.GetInt32(1)))

Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Using

When I execute, the line, "Dim reader As OracleDataReader =
command.ExecuteReader()" raises an exception, "{"Parameter 'P_ERROR': No size
set for variable length data type: String."}

What am I doing wrong?
Oct 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: rvdw | last post by:
Hi All, I've a serious problem with executing stored procedures (SQL2000) from an Access db (version 97). After executing a stored procedure , msaccess hangs. The whole call to the procedure is...
3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
1
by: rvdw | last post by:
Hi All, I've a serious problem with executing stored procedures (SQL2000) from an Access db (version 97). After executing a stored procedure , msaccess hangs. The whole call to the procedure is...
1
by: Ville Huovinen | last post by:
Platform: Windows 2003 Server (MS SQL Server 2003 SP3) Language: C# Problem: My stored procedures times out randomly, some proces works fine when using them from C#, and some generate...
4
by: Stuart Ferguson | last post by:
I am currently writing code to execute SQL Server 2000 Stored procedured using the ODBC.NET SQL Server Driver. The particular stored procedure I am using has multiple paramaters which I have...
1
by: A1 Ronen | last post by:
Hi all I got problem regarding executing all stored procedure through common procedures where we have different parameter with different names, type and data type The Function is as follows...
9
by: Leedrick | last post by:
Hi, In the past I have been dealing mainly with sql server, and recently been given the task of supporting software that uses db2 on as400. Simple tasks such as executing a stored procedure...
2
by: staeri | last post by:
When I execute a stored procedure with the following code it takes forever and result in a timeout or a hang: Sub TransformData() Dim myConnection As New SqlConnection(ConnectionString) Dim...
2
by: Carlton Kirby | last post by:
I need to execute a job on a SQL Express 2005 instance (no SQLAgent). The job will be executed manually by a user, so it doesn't need to be scheduled to run automatically. I thought I could...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.