Page 1 of 1

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

Posted: Tue 19 Jan 2010 06:40
by Infomaster
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!

Posted: Tue 19 Jan 2010 10:04
by Plash
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.