考试网 >> IT认证 >> Oracle >> Oracle指导 >> 在Oracle中返回多个结果集的方法

在Oracle中返回多个结果集的方法

发布时间:2006-06-28 10:06     点击:
分页:上一页  1 [2] 3  下一页

    OracleCommand cmd = new OracleCommand();

    cmd.Connection = conn;

    cmd.CommandText = "SELECT_EMPLOYEES_JOBS.GetEmployeesAndJobs";

    add the parameters including the two REF CURSOR types to retrieve

    the two result sets

    cmd.Parameters.Add("cur_Employees", OracleType.Cursor).Direction =

    ParameterDirection.Output;

    cmd.Parameters.Add("cur_Jobs", OracleType.Cursor).Direction =

    ParameterDirection.Output;

    cmd.CommandType = CommandType.StoredProcedure;

    create the DataAdapter and map tables

    OracleDataAdapter da = new OracleDataAdapter(cmd);

    da.TableMappings.Add("Table", "EMPLOYEES");

    da.TableMappings.Add("Table1", "JOBS");

    create and fill the DataSet

    DataSet ds = new DataSet();

    da.Fill(ds);

    create a relation

    ds.Relations.Add("EMPLOYEES_JOBS_RELATION",

    ds.Tables["JOBS"].Columns["JOB_ID"],

    ds.Tables["EMPLOYEES"].Columns["JOB_ID"]);

    output the second employee (zero-based array) and job title

    based on the relation

    Console.WriteLine("Employee ID: " +

    ds.Tables["EMPLOYEES"].Rows[1]["EMPLOYEE_ID"] +

    "; Job Title: " +

    ds.Tables["EMPLOYEES"].Rows[1].GetParentRow(

    "EMPLOYEES_JOBS_RELATION")["JOB_TITLE"]);
分页:上一页  1 [2] 3  下一页
版权申明:未经书面授权请勿转载本站信息!!作品版权归所属媒体与作者所有!!
发表评论: 匿名发表 用户名: 查看评论
您将承担一切因您的行为、言论而直接或间接导致的民事或刑事法律责任
留言板管理人员有权保留或删除其管辖留言中的任意内容
本站提醒:不要进行人身攻击。谢谢配合。
在本站搜索相关信息
2003-2005 Ksw123.com All Rights Reserved. - TOP
Copyright © 2006 Ksw123.com. All rights reserved.中国考题网 版权所有