PC Review


Reply
Thread Tools Rate Thread

call a STORED PROCEDURE (oracle) from C#

 
 
RicercatoreSbadato
Guest
Posts: n/a
 
      16th Jun 2006
I have a procedure with a lot of parameters:

....
var IN BOOLEAN DEFAULT FALSE,
....

and one variable is a boolean.

How can I put the bool parameter into this stored procedure from c#?

I've tried :

OracleParameter op5 = new OracleParameter("var", 1);
op5.Direction = ParameterDirection.Input;
cmd.Parameters.Add(op5);

but I receive always the same error:

System.Data.OracleClient.OracleException: ORA-06550: riga 1, colonna 7:
PLS-00306: numero o tipi di argomenti errati nella chiamata di 'myproc'
ORA-06550: riga 1, colonna 7:
PL/SQL: Statement ignored

Any idea ?

 
Reply With Quote
 
 
 
 
Frans Bouma [C# MVP]
Guest
Posts: n/a
 
      16th Jun 2006
RicercatoreSbadato wrote:

> I have a procedure with a lot of parameters:
>
> ...
> var IN BOOLEAN DEFAULT FALSE,
> ...
>
> and one variable is a boolean.
>
> How can I put the bool parameter into this stored procedure from c#?
>
> I've tried :
>
> OracleParameter op5 = new OracleParameter("var", 1);
> op5.Direction = ParameterDirection.Input;
> cmd.Parameters.Add(op5);
>
> but I receive always the same error:
>
> System.Data.OracleClient.OracleException: ORA-06550: riga 1, colonna
> 7: PLS-00306: numero o tipi di argomenti errati nella chiamata di
> 'myproc' ORA-06550: riga 1, colonna 7:
> PL/SQL: Statement ignored
>
> Any idea ?


BOOLEAN is a surrogate type, you should simply pass a NUMBER value.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
Reply With Quote
 
David Browne
Guest
Posts: n/a
 
      16th Jun 2006

"RicercatoreSbadato" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a procedure with a lot of parameters:
>
> ...
> var IN BOOLEAN DEFAULT FALSE,
> ...
>
> and one variable is a boolean.
>
> How can I put the bool parameter into this stored procedure from c#?
>
> I've tried :
>
> OracleParameter op5 = new OracleParameter("var", 1);
> op5.Direction = ParameterDirection.Input;
> cmd.Parameters.Add(op5);
>
> but I receive always the same error:
>
> System.Data.OracleClient.OracleException: ORA-06550: riga 1, colonna 7:
> PLS-00306: numero o tipi di argomenti errati nella chiamata di 'myproc'
> ORA-06550: riga 1, colonna 7:
> PL/SQL: Statement ignored
>


There are a number of PL/SQL types that aren't directly accessable from
..NET. The general solution to those situations is to code a custom PL/SQL
block that marshals .NET compatible types.


Use an OracleCommand with CommandType.Text something like

DECLARE
lnum NUMBER(1) := Var;
lvar BOOLEAN;
BEGIN
if lnum = 1
lvar := TRUE;
elsif
lvar := FALSE;
endf;

MyOracleProc(lvar);
END;


Here pVar is a bind variable, and you would bind a numeric OracleParameter
to it.

David

 
Reply With Quote
 
RicercatoreSbadato
Guest
Posts: n/a
 
      19th Jun 2006
I've called a function() from a select. This function() calls the
procedure. I've solved the problem in this way. Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Excel to call Oracle Stored procedure. pdcjlw1 Microsoft Excel Programming 1 9th Jul 2009 05:17 PM
how to call Oracle Stored Procedure from MS ACCESS 2007 VB csidb Microsoft Access VBA Modules 5 11th Oct 2008 12:44 AM
Call Oracle Stored Procedure from Access Jeremy Ellison Microsoft Access 1 22nd Mar 2008 09:05 PM
How to call a Stored Procedure in Oracle having Boolean IN paramet =?Utf-8?B?Skxv?= Microsoft ADO .NET 2 28th Jul 2005 06:05 PM
Call Oracle Stored Procedure Frank Microsoft Access VBA Modules 1 25th Sep 2004 10:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:09 PM.