"Command Out of Sync" error for TMyQuery when call stored procedure return more than 1 resultsets.

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
chintatlim
Posts: 22
Joined: Tue 09 Nov 2004 00:31

"Command Out of Sync" error for TMyQuery when call stored procedure return more than 1 resultsets.

Post by chintatlim » Mon 13 Mar 2006 03:33

"Command Out of Sync" error for TMyQuery when call stored procedure return more than 1 resultsets.

MyDAC Version: 4.30.0.11
Delphi 7

SQL as below:

delimiter $$

Drop Procedure If Exists test $$

Create Procedure test()
begin
select 1;
select 2;
end $$

call test() $$

Drop Procedure If Exists test $$

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

The First bug of myDAC 4.30.0.11

Post by eduardosic » Mon 13 Mar 2006 05:16

I made a test with its code, the error I happen in the second execution of procedure, this error I also happen with ' TMyStoredProc '.

the error happens in such a way with TmyConnection.Direct = False or TmyConnection.Direct = True
and
TmyQuery.FetchAll = False or TmyQuery.FetchAll = True

if procedure to possess only one Select the error does not happen. I tested procedure with 2 select in the console of mySQL and I functioned perfectly but so is shown the result of second "select"


****
Delphi 7.0 Build 4.453
myDAC 4.30.0.11
mySQL server 5.0.18-nt-max

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 13 Mar 2006 14:13

The error happens because this stored procedure returns two resultsets. You shoud call StoredProc.OpenNext until all the resultsets are received. For this example you should use something like this:

Code: Select all

 
  MyStoredProc.Execute;
  ...
  MyStoredProc.OpenNext;
  ...
  MyStoredProc.Execute;
  ...
  MyStoredProc.OpenNext;
  ...
Note: OpenNext works only if FetchAll=False.

Post Reply