能从存储过程返回一些什么东西啊?

[复制链接]
查看11 | 回复6 | 2005-10-30 17:05:33 | 显示全部楼层 |阅读模式
因为存储过程比其他ado程序快一点,因此我想。。。。(内)
我想吧在一个8000万表里面查询一条数据也写道存储过程里面,可是,存储过程只返回一个一个的变量,晕死!!!
不知道存储过程有没有批量返回结果的具体做法啊?
比如说:
1。某个条件查询倒了20条数据,将20条数据作为一个集合什么的来返回(我不知道师是否存储过程有这样的做法的)
谢谢,谢谢!
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
比较急!
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
有呀,出参需要用自定义的表类型
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
能否代码提点一些啊,比较,比较急!
自定义的表类型(表?表类型??)
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
看一下书,关于compositedatatype和collect的知识,就明白啦~
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
ado我不知道,但是用ado.net请参考ms.net oracle客户端
帮助文件
Creating the Oracle Tables
These examples use tables that are defined in the Oracle Scott/Tiger schema. By default, the Oracle Scott/Tiger schema is included with a standard Oracle installation. However, if this schema does not exist, you can use the SQL commands file in {OracleHome}\rdbms\admin\scott.sql to create the tables and indexes used by these examples.
Creating the Oracle Package and Package Body
These examples require the following PL/SQL package and package body. You must create these on your server to use the examples.
Create the following Oracle package on the Oracle server.
CREATE OR REPLACE PACKAGE CURSPKG AS
TYPE T_CURSOR IS REF CURSOR;
PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER,

IO_CURSOR IN OUT T_CURSOR);
PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR,

DEPTCURSOR OUT T_CURSOR);
END CURSPKG;
/
Create the following Oracle package body on the Oracle server.
CREATE OR REPLACE PACKAGE BODY CURSPKG AS
PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER,

IO_CURSOR IN OUT T_CURSOR)
IS
V_CURSOR T_CURSOR;
BEGIN
IF N_EMPNO0
THEN

OPEN V_CURSOR FOR

SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME

FROM EMP, DEPT

WHERE EMP.DEPTNO = DEPT.DEPTNO

AND EMP.EMPNO = N_EMPNO;
ELSE

OPEN V_CURSOR FOR

SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME

FROM EMP, DEPT

WHERE EMP.DEPTNO = DEPT.DEPTNO;
END IF;
IO_CURSOR := V_CURSOR;
END OPEN_ONE_CURSOR;
PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR,

DEPTCURSOR OUT T_CURSOR)
IS
V_CURSOR1 T_CURSOR;
V_CURSOR2 T_CURSOR;
BEGIN
OPEN V_CURSOR1 FOR SELECT * FROM EMP;
OPEN V_CURSOR2 FOR SELECT * FROM DEPT;
EMPCURSOR:= V_CURSOR1;
DEPTCURSOR := V_CURSOR2;
END OPEN_TWO_CURSORS;
END CURSPKG;
/
This Microsoft® Visual Basic® example executes a PL/SQL stored procedure that returns two REF CURSOR parameters, and fills a DataSet with the rows that are returned.
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connString As New String("Data Source=Oracle8i;Integrated Security=yes&quot


Dim ds As New DataSet()
Dim conn As New OracleConnection(connString)
Dim cmd As New OracleCommand()
cmd.Connection = conn
cmd.CommandText = "CURSPKG.OPEN_TWO_CURSORS"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New OracleParameter("EMPCURSOR", OracleType.Cursor)).Direction = ParameterDirection.Output
cmd.Parameters.Add(New OracleParameter("DEPTCURSOR", OracleType.Cursor)).Direction = ParameterDirection.Output
Dim da As New OracleDataAdapter(cmd)
Try
da.Fill(ds)
Catch Myex As Exception
MessageBox.Show(Myex.Message.ToString)
End Try
ds.Relations.Add("EmpDept", ds.Tables(0).Columns("Deptno&quot

, ds.Tables(1).Columns("Deptno&quot

, False)
DataGrid1.DataSource = ds.Tables(0)
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
这是.NET Framework Data Provider for Oracle中文帮助
dll请自行下载安装
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行