Why i can't use first parameter of TOraStoredProc like all other parameters, when then they are cursors?

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Infomaster
Posts: 6
Joined: Mon 11 Jan 2010 13:26

Why i can't use first parameter of TOraStoredProc like all other parameters, when then they are cursors?

Post by Infomaster » Tue 19 Jan 2010 06:40

Hi!

Look, i have some stored procedure in my database:

Code: Select all

PACKAGE BODY pkg_Test AS

  PROCEDURE TestProc(
    aMessage OUT VARCHAR2,
    aCursor1  OUT SYS_REFCURSOR,
    aCursor2  OUT SYS_REFCURSOR
  ) IS
  BEGIN
    aMessage := 'Hello';
    OPEN aCursor1 FOR
      SELECT 'First Cursor'
      FROM Dual;
    OPEN aCursor2 FOR
      SELECT 'Second Cursor'
      FROM Dual;
  END;

END;
When I tried to get second cursor like this:

Code: Select all

MyOraQuery.Cursor := MyOraStoredProc.Params[2].AsCursor;
MyOraQuery.Open;
Its all OK.
But when I tried to get first cursor:

Code: Select all

MyOraQuery.Cursor := MyOraStoredProc.Params[1].AsCursor;
MyOraQuery.Open;
I have no data in a MyOraQuery!
Only this works:

Code: Select all

MyOraQuery.Assign(MyOraStoredProc);
MyOraQuery.Open;
But why?
I tried with a different params but any time when i have cursor in them its doesnt not works with first cursor of params, all other cursors works fine.

Thanks!

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 19 Jan 2010 10:04

TOraStoredProc opens the first cursor inside the component itself.

Use TOraSQL to prevent this. Copy the SQL statement from TOraStoredProc to TOraSQL and execute the procedure using TOraSQL.

Post Reply