How to do CASE statements

Posts   
 
    
G.I.
User
Posts: 172
Joined: 09-Jun-2005
# Posted on: 04-Jul-2005 09:57:30   

Hi, I have this CASE statement that I need to implement somehow in my entity:

'contract_type' = case when NOT max(CT3.CONTRACT_CODE) IS NULL then max(CT3.CONTRACT_CODE) when NOT max(CT.CONTRACT_CODE) IS NULL then max(CT.CONTRACT_CODE) else max(CT2.CONTRACT_CODE) end,

CT, CT2 and CT3 are all joins to one table based on different criteria.

How do I do this?!? Is the only way using the iPredicate implementation and if so, how exactly do I emit this string directly into the query? Can someone please provide some code?

Thanks in advance,

G.I.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 04-Jul-2005 10:19:12   

Please move this code to the client. So return MAX(...) as the value and use NULL testing/handling code in your client code instead of in a CASE statement.

Frans Bouma | Lead developer LLBLGen Pro
G.I.
User
Posts: 172
Joined: 09-Jun-2005
# Posted on: 04-Jul-2005 11:06:42   

Hmmm...ok, so then I will have to add three related fields to get this data to be able to set one other field to hold the correct value?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 04-Jul-2005 11:17:18   

G.I. wrote:

Hmmm...ok, so then I will have to add three related fields to get this data to be able to set one other field to hold the correct value?

Yes, as case isn't supported at the moment.

Frans Bouma | Lead developer LLBLGen Pro