有关存储过程返加结果集,及DELPHI显示结果集方法代码如下;
存储过程返加结果集
1、生成一TEST表
create table test( a number,b number);
insert into test values(111,222);
insert into test values(11,22);
insert into test values(1,2);
2、生成一个包
CREATE OR REPLACE PACKAGE TypeDefine
AS
TYPE Cursor_Test IS REF CURSOR RETURN Test%ROWTYPE;
END;
3、生成一个存储过程;
CREATE OR REPLACE PROCEDURE sp_test
(resultData IN OUT TypeDefine.Cursor_Test)
AS
BEGIN
OPEN resultData FOR
SELECT a,b from test;
END;
4、在ORACLE中执行测试:
VARIABLE v REFCURSOR;
EXECUTE sp_test
v);
PRINT :v;
5、在DELPHI显示结果集:
需用控件StoredProc1、DataSource1、DBGrid1
StoredProc1=SP_TEST,参数RESULTDATA=ftCursor,设StoredProc1=TRUE
可从 DBGrid1看到所返加的结果集