Query must return exactly one result set - use Execute
Posted: Tue 26 Jul 2011 15:00
Hi, I'm busy migrating from a BDE project to SDAC 5. On one of the queries (TMSQuery) I have migrated, I receive the following error:
'Query must return exactly one result set - use Execute.'
The only thing I changed was to migrate from InfoPower's TwwQuery component to TMSQuery.
Here is the SQL property of the query component:
declare @Next integer
select @Next = max(ProfileListHeadNbr) + 1
from Communicationprofilelisthead
if (@next is null)
select @next = 1000
insert into Communicationprofilelisthead
select distinct @Next,getDate(),null
select @Next NextKey
Here is the code that triggers the error:
with TMSQueryInsertCommHeader do
begin
close;
prepare;
open; // <-- Error occurs here (I have tried using Execute instead but it still gives this error)
end;
bCommHeaderGen := true;
StoreHeaderNumber :=
wwQueryInsertCommHeaderNextKey.value;
When I run the SQL code in SQL query analyzer, it works fine. Additionally, this error does not occur if I use Delphi's ADO components.
Kindly let me know where the problem could be.
Thank you.
'Query must return exactly one result set - use Execute.'
The only thing I changed was to migrate from InfoPower's TwwQuery component to TMSQuery.
Here is the SQL property of the query component:
declare @Next integer
select @Next = max(ProfileListHeadNbr) + 1
from Communicationprofilelisthead
if (@next is null)
select @next = 1000
insert into Communicationprofilelisthead
select distinct @Next,getDate(),null
select @Next NextKey
Here is the code that triggers the error:
with TMSQueryInsertCommHeader do
begin
close;
prepare;
open; // <-- Error occurs here (I have tried using Execute instead but it still gives this error)
end;
bCommHeaderGen := true;
StoreHeaderNumber :=
wwQueryInsertCommHeaderNextKey.value;
When I run the SQL code in SQL query analyzer, it works fine. Additionally, this error does not occur if I use Delphi's ADO components.
Kindly let me know where the problem could be.
Thank you.