Oracle Stored Procedure

G

Guest

If you have created an oracle function which returns a single value, can you
use the "ExecuteScalar" method to return that value? I have tried and I
continue to get an error (Object not set). I have coded my parameter name as
being "RetVal" with an output type of "returnValue". Why can't I run the
"ExecuteScalar" method? I have wrapped a procedure around the function an
called the procedure with a datareader, that works, but it seems that I
should be able to use the "ExecuteScalar" method. Is there a way?
 
F

Frans Bouma [C# MVP]

Jim said:
If you have created an oracle function which returns a single value, can
you use the "ExecuteScalar" method to return that value? I have tried and I
continue to get an error (Object not set). I have coded my parameter name
as being "RetVal" with an output type of "returnValue". Why can't I run
the "ExecuteScalar" method? I have wrapped a procedure around the function
an called the procedure with a datareader, that works, but it seems that I
should be able to use the "ExecuteScalar" method. Is there a way?

is the function in a package? It should be callable then. Scalar functions
do not work with output parameters as the value to return, you should think
of queries like:
SELECT bla FROM DUAL;

Frans.
 
R

Roy Fine

Jim

Try using ExecuteNonQuery - ExecuteScalar is best used when you want only
the first column of the first row of the results set. The advantage of
ExecuteScalr versus Execute is that, while ExecuteScalar does operate on a
rowset, it does not suffer all of the overhead necessary to construct then
tear down the client side data structure necessary to represent the rowset.

Here is a link relating to Oracle functions (using ODP.Net):
http://www.onecustomer.com/TechArticles/TechArt19.html

regards
roy fine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top