473,385 Members | 1,872 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,385 software developers and data experts.

run oracle stored procedure from c#

Hello.
I have an oracle connection and I'm trying to run a stored procedure.

The code for defining the parameters in C# is:
------------------------------
cmd.commandType = CommandType.storedProcedure;
//Parameter 1:
OracleParameter prm1 = new OracleParameter("c1",OracleDbType.VARCHAR2);
prm1.Direction = ParameterDirection.Output;
prm1.Value = '1';
cmd.Parameters.add(prm1);

//Parameter 2:
OracleParameter prm2 = new OracleParameter("c2",OracleDbType.VARCHAR2,
200);
prm1.Direction = ParameterDirection.Output;
cmd.Parameters.add(prm2);

cmd.ExecutenonQuery();
--------------------------------------
The stored Procedure in Oracle (10g) is:

create or replace procedure test (c1 in varchar2, c2 out varchar2) is
Begin
c2:='1';
End test
\
--------------------------------------

The error I'm having is:
"ORA-06502: numeric or value error:charecter string buffer is too
small"

I saw that error in few sites but not something like my problem?

Any idea?

Thanks.

Jan 8 '07 #1
5 7306
AB
I see some typos ...

"nicknack" <ro******@gmail.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
//Parameter 1:
OracleParameter prm1 = new OracleParameter("c1",OracleDbType.VARCHAR2);
prm1.Direction = ParameterDirection.Output;
--Input instead of Output ??
prm1.Value = '1';
cmd.Parameters.add(prm1);

//Parameter 2:
OracleParameter prm2 = new OracleParameter("c2",OracleDbType.VARCHAR2,
200);
prm1.Direction = ParameterDirection.Output;
^^^^
--prm2
Any idea?

Thanks.
n/p
Jan 8 '07 #2
Hey man
Finally i can help

when you create the OracleParameter that will contain the output value
of a SP, you should use the constructor's overload that receives a
value as well, and pass there the String.Empty value.

Enjoy!
nicknack ëúá:
Hello.
I have an oracle connection and I'm trying to run a stored procedure.

The code for defining the parameters in C# is:
------------------------------
cmd.commandType = CommandType.storedProcedure;
//Parameter 1:
OracleParameter prm1 = new OracleParameter("c1",OracleDbType.VARCHAR2);
prm1.Direction = ParameterDirection.Output;
prm1.Value = '1';
cmd.Parameters.add(prm1);

//Parameter 2:
OracleParameter prm2 = new OracleParameter("c2",OracleDbType.VARCHAR2,
200);
prm1.Direction = ParameterDirection.Output;
cmd.Parameters.add(prm2);

cmd.ExecutenonQuery();
--------------------------------------
The stored Procedure in Oracle (10g) is:

create or replace procedure test (c1 in varchar2, c2 out varchar2) is
Begin
c2:='1';
End test
\
--------------------------------------

The error I'm having is:
"ORA-06502: numeric or value error:charecter string buffer is too
small"

I saw that error in few sites but not something like my problem?

Any idea?

Thanks.
Jan 8 '07 #3
Hi victor.

I didn't find any overload thet receive a value (I'm with VS2005 and I
added refference to the ODP dll of oracle).

What I did manage to do is to give the parameter a value:
prm3.value ='1'
and it worked but when i gave him string.Empty i got the same error.

Thanks.

Victor Rosenberg כתב:
Hey man
Finally i can help

when you create the OracleParameter that will contain the output value
of a SP, you should use the constructor's overload that receives a
value as well, and pass there the String.Empty value.

Enjoy!
nicknack ëúá:
Hello.
I have an oracle connection and I'm trying to run a stored procedure.

The code for defining the parameters in C# is:
------------------------------
cmd.commandType = CommandType.storedProcedure;
//Parameter 1:
OracleParameter prm1 = new OracleParameter("c1",OracleDbType.VARCHAR2);
prm1.Direction = ParameterDirection.Output;
prm1.Value = '1';
cmd.Parameters.add(prm1);

//Parameter 2:
OracleParameter prm2 = new OracleParameter("c2",OracleDbType.VARCHAR2,
200);
prm1.Direction = ParameterDirection.Output;
cmd.Parameters.add(prm2);

cmd.ExecutenonQuery();
--------------------------------------
The stored Procedure in Oracle (10g) is:

create or replace procedure test (c1 in varchar2, c2 out varchar2) is
Begin
c2:='1';
End test
\
--------------------------------------

The error I'm having is:
"ORA-06502: numeric or value error:charecter string buffer is too
small"

I saw that error in few sites but not something like my problem?

Any idea?

Thanks.
Jan 9 '07 #4
Hi
I am not entirely sure (i dont have VS installed at home), but i think
there is some kind of CreateParameter function, within the command
object, or perhaps the connection, with lots of overloads, and one of
them is just as I've described before
nicknack כתב:
Hi victor.

I didn't find any overload thet receive a value (I'm with VS2005 and I
added refference to the ODP dll of oracle).

What I did manage to do is to give the parameter a value:
prm3.value ='1'
and it worked but when i gave him string.Empty i got the same error.

Thanks.

Victor Rosenberg כתב:
Hey man
Finally i can help

when you create the OracleParameter that will contain the output value
of a SP, you should use the constructor's overload that receives a
value as well, and pass there the String.Empty value.

Enjoy!
nicknack ëúá:
Hello.
I have an oracle connection and I'm trying to run a stored procedure.
>
The code for defining the parameters in C# is:
------------------------------
cmd.commandType = CommandType.storedProcedure;
//Parameter 1:
OracleParameter prm1 = new OracleParameter("c1",OracleDbType.VARCHAR2);
prm1.Direction = ParameterDirection.Output;
prm1.Value = '1';
cmd.Parameters.add(prm1);
>
//Parameter 2:
OracleParameter prm2 = new OracleParameter("c2",OracleDbType.VARCHAR2,
200);
prm1.Direction = ParameterDirection.Output;
cmd.Parameters.add(prm2);
>
cmd.ExecutenonQuery();
--------------------------------------
The stored Procedure in Oracle (10g) is:
>
create or replace procedure test (c1 in varchar2, c2 out varchar2) is
Begin
c2:='1';
End test
\
--------------------------------------
>
The error I'm having is:
"ORA-06502: numeric or value error:charecter string buffer is too
small"
>
I saw that error in few sites but not something like my problem?

Any idea?

Thanks.
Jan 11 '07 #5
Hey man
Ignore my last message, here's the constuctor overload to use:
Declaration
// C#
public OracleParameter(string parameterName, OracleDbType type, object
obj,
ParameterDirection direction);

You can read more on
http://download-uk.oracle.com/docs/c...s.htm#i1011428

nicknack כתב:
Hi victor.

I didn't find any overload thet receive a value (I'm with VS2005 and I
added refference to the ODP dll of oracle).

What I did manage to do is to give the parameter a value:
prm3.value ='1'
and it worked but when i gave him string.Empty i got the same error.

Thanks.

Victor Rosenberg כתב:
Hey man
Finally i can help

when you create the OracleParameter that will contain the output value
of a SP, you should use the constructor's overload that receives a
value as well, and pass there the String.Empty value.

Enjoy!
nicknack ëúá:
Hello.
I have an oracle connection and I'm trying to run a stored procedure.
>
The code for defining the parameters in C# is:
------------------------------
cmd.commandType = CommandType.storedProcedure;
//Parameter 1:
OracleParameter prm1 = new OracleParameter("c1",OracleDbType.VARCHAR2);
prm1.Direction = ParameterDirection.Output;
prm1.Value = '1';
cmd.Parameters.add(prm1);
>
//Parameter 2:
OracleParameter prm2 = new OracleParameter("c2",OracleDbType.VARCHAR2,
200);
prm1.Direction = ParameterDirection.Output;
cmd.Parameters.add(prm2);
>
cmd.ExecutenonQuery();
--------------------------------------
The stored Procedure in Oracle (10g) is:
>
create or replace procedure test (c1 in varchar2, c2 out varchar2) is
Begin
c2:='1';
End test
\
--------------------------------------
>
The error I'm having is:
"ORA-06502: numeric or value error:charecter string buffer is too
small"
>
I saw that error in few sites but not something like my problem?

Any idea?

Thanks.
Jan 11 '07 #6

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

Similar topics

13
by: kristoff plasun | last post by:
I have a problem with a C++ DCOM application that prints Crystal Reports with data from Oracle. The SQL query is relatively complex but when the report is printed from the Crystal Reports...
0
by: Chan | last post by:
Hi, I am trying to send set of rows from my c# web service to Oracle stored procedure. I think I can get this done using OpenXML in SQL Server. How to implement this in Oracle Stored...
1
by: robin via SQLMonster.com | last post by:
I've tried several different way to execute a oracle stored procedure from a DTS package but to no avail. I have a Linked Server setup which does bring back Oracle tables from the server when I...
11
by: jrefactors | last post by:
I want to know the differences between SQL Server 2000 stored procedures and oracle stored procedures? Do they have different syntax? The concept should be the same that the stored procedures...
0
by: totierne | last post by:
comp.databases.ms-access, I want to know how to use Oracle views with session variables in Access. The parameterised views in access, are migrated to views with per session variables. The...
0
by: Chan | last post by:
Hi, I am trying to send set of rows from my c# web service to Oracle stored procedure. I think I can get this done using OpenXML in SQL Server. How to implement this in Oracle Stored...
1
by: Chad | last post by:
Hi, I am a SQL Server programmer using Oracle for the first time. In our .NET client apps which use a SQL Server back end, we would use Stored Procedure exclusively for all database access for...
0
by: Tom | last post by:
Looking for some help with stored procedure call issues. Conceptually, I need to pass a data structure as the sole parameter to the Oracle stored procedure. Sounds simple enough....but how? ...
14
by: jehugaleahsa | last post by:
Hello: I am working with Oracle .NET Stored Procedures. I would like to know how to return the results of a SELECT statement. I have tried returning a OracleRefCursor and a DataTable, but...
23
by: Gloops | last post by:
Hello everybody, Is anyone able to give me some indications about how to develop an Access interface for an Oracle database ? I dispose of Access 2003 (11.6566.8107) SP2, Oracle 9i 9.2.0.1.0...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.