求DOA(Direct Oracle Access)调用带参数存储过程的例子,最好有返回游标的。

sandygood 2003-10-16 04:06:59
我的邮箱是sandygood@sina.com
谢谢!!!
...全文
49 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sandygood 2003-10-17
  • 打赏
  • 举报
回复
好,全面,结贴了!!!
jianghfonline 2003-10-16
  • 打赏
  • 举报
回复
Example - Cursor variables
Since Version 7.2 Oracle supports cursor variables. These variables are a reference to a cursor for a select statement that is defined and opened on the server. They offer the following advantages:
 Cursors are defined and maintained on a central point on the server
 An end-user needs only execute privileges on the procedure, not on the underlying objects of the cursors
Using a cursor variable as a TOracleQuery
Because a cursor variable is equivalent to a TOracleQuery with a select statement, DOA implements the cursor variable type as a TOracleQuery. To use a cursor variable, you need at least two TOracleQuery components: one with a PL/SQL block to call the procedure that opens the cursor, and one for the cursor itself:
begin
with Query1 do
begin
Clear;
SQL.Add('begin');
SQL.Add(' employee.opencursor(:p_empcursor, :p_order)');
SQL.Add('end;');
DeclareVariable('p_empcursor', otCursor);
DeclareVariable('p_order', otString);
SetComplexVariable('p_empcursor', CursorQuery);
SetVariable('p_order', 'ename');
Execute;
end;
with CursorQuery do
begin
Execute;
while not Eof do
begin
Memo.Items.Add(Field('ename'));
Next;
end;
end;
end;

The packaged procedure employee.opencursor might look like this:
type t_empcursor is ref cursor return emp%rowtype;

procedure getcursor(p_empcursor in out t_empcursor, p_order in varchar2) is
begin
if p_order = 'ename' then
open p_empcursor for select * from emp order by ename;
elsif p_order = 'empno'
open p_empcursor for select * from emp order by empno;
else
open p_empcursor for select * from emp;
end if;
end;

In this example, Query1 calls the packaged function employee.opencursor to open a cursor to select all employees in a certain order. The CursorQuery is assigned to the p_empcursor variable. You need to use the SetComplexVariable method for this. Next, all rows are fetched and the employee names are displayed in a memo.

2,495

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧