时间:2021-07-01 10:21:17 帮助过:2人阅读
2、建立包体
create or replace package body QX_GDJTJ is PROCEDURE GETGDJQXTJ ( cur_id in varchar, cur_GDJQXTJ1 OUT T_CURSOR, cur_GDJQXTJ2 OUT T_CURSOR, cur_GDJQXTJ3 OUT T_CURSOR ) IS BEGIN OPEN cur_GDJQXTJ1 FOR select (select count(0) from HVM_VIEW_QX where voltage=‘500kV‘ and gdjid=cur_id )-(select count(0) from HVM_VIEW_QX where voltage=‘500kV‘ and gdjid=cur_id and cljg like ‘%合格%‘ and cljg not like ‘%不合格%‘) from dual; OPEN cur_GDJQXTJ2 FOR select (select count(0) from HVM_VIEW_QX where voltage=‘220kV‘ and gdjid=cur_id )-(select count(0) from HVM_VIEW_QX where voltage=‘220kV‘ and gdjid=cur_id and cljg like ‘%合格%‘ and cljg not like ‘%不合格%‘) from dual; OPEN cur_GDJQXTJ3 FOR select (select count(0) from HVM_VIEW_QX where voltage=‘110kV‘ and gdjid=cur_id )-(select count(0) from HVM_VIEW_QX where voltage=‘110kV‘ and gdjid=cur_id and cljg like ‘%合格%‘ and cljg not like ‘%不合格%‘) from dual; end GETGDJQXTJ; end QX_GDJTJ;
3、C#调用,返回结果集
public static DataSet GetDataSet(string gdjId, string proName, string[] cursors) { OracleConnection Conn = GetConn(); DataSet ds = new DataSet(); try { OracleCommand cmd = new OracleCommand(); cmd.Connection = Conn; cmd.CommandText = proName; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("cur_id", OracleType.VarChar).Value = gdjId; for (int i = 0; i < cursors.Length; i++) { cmd.Parameters.Add(cursors[i], OracleType.Cursor).Direction = ParameterDirection.Output; } OracleDataAdapter da = new OracleDataAdapter(cmd); da.Fill(ds); } catch (System.Data.OracleClient.OracleException ex) { throw new Exception(ex.Message); } finally { Conn.Close(); } return ds; }
Oracle :一次数据库连接,返回多个结果集
标签: