asp.net - Oracle query/ stored procedure to return multiple resultsets -


i using oracle database. when tried fetch data using single select query, returned single table in dataset. how write select query or procedure in oracle, can dataset 2-3(multiple) tables?

as far understood question reduce round trips database. can done stored procedure in following way:

http://msdn.microsoft.com/en-us/library/ms971506.aspx#msdnorsps_topic6

package header:

create or replace package select_job_history type t_cursor ref cursor; procedure getjobhistorybyemployeeid (     p_employee_id in number,     cur_jobhistory out t_cursor ); end select_job_history; 

package:

create or replace package body select_job_history procedure getjobhistorybyemployeeid (     p_employee_id in number,     cur_jobhistory out t_cursor ) begin     open cur_jobhistory     select * job_history         employee_id = p_employee_id;  end getjobhistorybyemployeeid; end select_job_history; 

client:

// create connection oracleconnection conn = new oracleconnection("data source=oracledb;     user id=userid;password=password;");  // create command stored procedure oraclecommand cmd = new oraclecommand(); cmd.connection = conn; cmd.commandtext = "select_job_history.getjobhistorybyemployeeid"; cmd.commandtype = commandtype.storedprocedure;  // add parameters stored procedure including ref cursor // retrieve result set cmd.parameters.add("p_employee_id", oracletype.number).value = 101; cmd.parameters.add("cur_jobhistory", oracletype.cursor).direction =     parameterdirection.output;  // open connection , create datareader conn.open(); oracledatareader dr = cmd.executereader();  // output results , close connection. while(dr.read()) {     for(int = 0; < dr.fieldcount; i++)         console.write(dr[i].tostring() + ";");     console.writeline(); } conn.close(); 

if have join these tables can use normal join , split result on client (imho way how lot of orms it).


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -