SQL Server Case output not working in Delphi TADODataSet

In Delphi XE5, I use TADODataSet and set its CommandText to this command (with CASE ) :

 SELECT Master.*, CASE ( SELECT TOP (1) personeli_State FROM Detail WHERE Detail.FK_Key = Master.pk_key AND Detail.personeli_State = 'Test' AND Detail.sended = 0 ) WHEN 'Test' THEN 'Test exist' ELSE '' END AS PersonState FROM Master LEFT OUTER JOIN ExtraInfo ON ExtraInfo.p_key = Master.fk_ExtraInfo WHERE (fk_key=:Fk) 

And the record set is empty, but without CASE contains a list of record records. (I cannot use a computed column or SQL Server view because I have a dynamic query)

+4
source share
1 answer

Change the Select section in the CASE statement below:

  CASE ( SELECT TOP (1) personeli_State FROM Detail WHERE Detail.personeli_State = 'Test' AND Detail.sended = 0 AND Detail.FK_Key = Master.pk_key ) 

In my opinion, it seems that ADO is changing the priority of the implementation plan ...!

+1
source

All Articles