How to return records from Oracle dynamic SQL in a stored procedure with ODP.NET -


i'am trying figure out how can result of dynamic sql query being held in store procedure.

the store procedure simple:

create or replace procedure port_call_procedeure(queryin in varchar2,result out varchar2)  begin     dbms_output.put_line(queryin);    execute immediate queryin;     end ; 

the way i'am calling vs is:

oraclecommand oracmd = getcommand("port_call_procedeure", oraconn); oraconn.open(); string row = string.empty; stringbuilder sb = new stringbuilder(); sb.append("select * result port = 'mso'and map = 'local'"); sb.append(" vessel"); string commandstring = sb.tostring(); command.parameters.add("query_in", oracledbtype.varchar2, 10000000,      commandstring, parameterdirection.input); command.parameters.add("result", oracledbtype.varchar2, 10000000,     `commandstring, parameterdirection.output);` oracmd.executenonquery(); 

i'am getting exception:

{"ora-00905: missing keyword   ora-06512: @ \"boaz.port_call_procedeure\", line 7   ora-06512: @ line 1"} 

any help? thanks.

this solution worked me:

oracle procedure code:

create or replace procedure port_call_procedeure   (queryin in varchar2, result out varchar2) begin    dbms_output.put_line(queryin);    execute immediate queryin result; end ; 

c# code:

oraclecommand oracmd = new oraclecommand("port_call_procedeure", oraconn); oracmd.commandtype = commandtype.storedprocedure; oracmd.parameters.add("query_in", oracledbtype.varchar2, 10000000,      "select * dual dummy='x'", parameterdirection.input); oracmd.parameters.add("result", oracledbtype.varchar2, 10000000,      null, parameterdirection.output); oracmd.executenonquery(); console.writeline(oracmd.parameters["result"].value); 

this work scalar, varchar values. result datatable need change types in oracle procedure sys_refcursor , in c# refcursor, (didn't test it).


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -