c# - Call a oracle function that returns a cursor -
i have oracle function takes input parameter , returns cursor. using c# invoke oracle function, however, not able retrieve cursor.
my oracle function call follows:-
select tbl_power_view.get_power_id('v') dual;
my c# code is:
conn = new oracleconnection(oracleserver); conn.open(); oraclecommand cmd = new oraclecommand(); cmd.commandtext = "tbl_power_view.get_power_id"; cmd.commandtype = commandtype.storedprocedure; cmd.connection = conn; oracleparameter powerid = new oracleparameter("i_power_flg", oracledbtype.varchar2); powerid.direction = parameterdirection.input; powerid.value = 'l'; cmd.parameters.add(powerid); oracleparameter orap = new oracleparameter(); orap.parametername = "test_cursor"; orap.oracledbtype = oracledbtype.refcursor; orap.direction = system.data.parameterdirection.output; cmd.parameters.add(orap); oracledataadapter adapter = new oracledataadapter(); adapter.selectcommand=cmd; dataset ds = new dataset(); adapter.fill(ds);
error stack follows:-
a first chance exception of type 'oracle.dataaccess.client.oracleexception' occurred in oracle.dataaccess.dll
oracle.dataaccess.client.oracleexception ora-06550: line 1, column 7:
pls-00306: wrong number or types of arguments in call 'test_cursor'
ora-06550: line 1, column 7:
pl/sql: statement ignored
do following
// use return instead of output in function orap.direction = parameterdirection.return;
!!! return parameter must listed first unless do
cmd.bindbyname = true;
this should take care of it
Comments
Post a Comment