cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect syntax near the keyword when

former_member645084
Participant
0 Kudos

Hi

Select 
(case 
when substring($[RDR1.U_Code], 1,5) = 'U_CMax then Select 'U_Max' from Oitm  where OITM.ItemCode =  $[RDR1.ITEMCODE]
when substring($[RDR1.U_Code], 1,5) = 'U_CApple then Select 'U_Apple' from Oitm  where OITM.ItemCode =  $[RDR1.ITEMCODE]
End)

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Johan_H
Active Contributor

Are you serious?

danishs.a. is showing you the problem:

'U_CMax then Select 'U_Max'

'U_CApple then Select 'U_Apple'

Besides missing a single quote on each line, the sub queries should each separately be enclosed in brackets:

'U_CMax' then (Select 'U_Max')
former_member645084
Participant
0 Kudos

Hi

I have below code but still not working

Select 
(case 
when substring($[RDR1.U_Code], 1,6) = 'U_CMax' then (Select U_Max from Oitm  where OITM.ItemCode =  $[RDR1.ITEMCODE])
when substring($[RDR1.U_Code], 1,6) = 'U_CApp' then (Select U_Apple from Oitm  where OITM.ItemCode =  $[RDR1.ITEMCODE])
End)

Thanks

Johan_H
Active Contributor

the separate cases must no themselves be enclosed in brackets:

Select 
case 
when substring($[RDR1.U_Code], 1,6) = 'U_CMax' then (select U_Max 
                                                     from OITM
                                                     where OITM.ItemCode =  $[RDR1.ITEMCODE])
when substring($[RDR1.U_Code], 1,6) = 'U_CApp' then (select U_Apple 
                                                     from OITM
                                                     where OITM.ItemCode =  $[RDR1.ITEMCODE])
End

Answers (1)

Answers (1)

MD1
Active Contributor
0 Kudos

not understand

what is this ..UDF or TEXT

'U_CMax then Select 'U_Max'

'U_CApple then Select 'U_Apple'
former_member645084
Participant
0 Kudos

Hi

U_Max & U_Apple are the UDF fields in Item Master

U_Code is the Udf in Rdr1

Select 
(case 
when substring($[RDR1.U_Code], 1,6) = 'U_CMax then Select 'U_Max' from Oitm  where OITM.ItemCode =  $[RDR1.ITEMCODE]
when substring($[RDR1.U_Code], 1,6) = 'U_CApp then Select 'U_Apple' from Oitm  where OITM.ItemCode =  $[RDR1.ITEMCODE]
End)