Page 1 of 1

SYS_REFCURSOR

Posted: Thu 13 May 2010 20:23
by Alladin
Sorry to bother you guys again,
I know that in Ukraine now is good weather, but...

I have a stored function:

Code: Select all

create or replace function TestStoredFunction() return sys_refcursor
as	
  result sys_refcursor;
begin
  open result for select 0 as Result, Sys_Guid() from dual;
  return result;
end;

Code: Select all

var cmd = conn.CreateCommand() 
{
   CommandType = CommandType.StoredProcedure,
   CommandText = "TestStoredFunction",
};
var reader = cmd.ExecuteReader();
Could anyone explain, why I'm getting exception:

Code: Select all

PLS-00221: 'TESTSTOREDFUNCTION' is not a procedure or is undefined
Why can't a call a stored function? What am I doing wrong?

Posted: Mon 17 May 2010 12:34
by StanislavK
To execute a stored function you need to populate the Parameters collection of the OracleCommand object. You may either add them manually or set the OracleCommand.ParameterCheck property to true.

Feel free to contact us if something is unclear.