// 给一个例子给你!
create or replace package PkgTest is
type TCursor is ref cursor;
procedure GetTableRecs(TbName in varchar2, p_Cursor out TCursor);
end PkgTest;
/
create or replace package body PkgTest is
procedure GetTableRecs(TbName in varchar2, p_Cursor out TCursor) is
v_SQL varchar2(1024);
begin
v_SQL := 'select * from ' || TbName;
open p_Cursor for
v_SQL;
end GetTableRecs;
end PkgTest;
/
客户端SQL我只用过DOA的:
var
Tblname: string;
AQuery, P_Cursor: TOracleQuery;
begin
P_Cursor := TOracleQuery.Create(nil);
P_Cursor.Session := Session;
with AQuery do
try
DeclareVariable('TBLNAME', otString);
SetVariable('TBLNAME', Tblname);
DeclareVariable('P_CURSOR', otCursor);
SetComplexVariable('P_CURSOR', P_Cursor);
SQL.Text := 'begin PkgTest.GetTableRecs
TBLNAME,
_CURSOR); end;';
Execute;
P_Cursor.Execute; //打开Cursor
except
P_Cursor.Free;
raise;
end;
end;