MikeDevenney
Programmer
Can anyone tell me what I'm doing wrong in the statement below? The sub-select in the first WHEN block works fine when not embedded in the CASE statement but I need to add the test for the message type (MT103 vs MT202) and return a different value for BeneficiaryCustomerAccount and some (but not all) other fields based on the result. Am I going about this the wrong way?
SELECT
foo,
bar,
(CASE
WHEN imt.imt_cde_msg_type = 'MT103' THEN Select rolbenc.ior_txt_acct_no from ls2user.tls_imt_out_role rolbenc where rolbenc.ior_rid_outgng_imt = imt.imt_rid_imt_out and rolbenc.ior_cde_swft_rtyp = 'BENCR'
WHEN imt.imt_cde_msg_type = 'MT202'
THEN '') as BeneficiaryCustomerAccount,
...
FROM
...
WHERE
...
SELECT
foo,
bar,
(CASE
WHEN imt.imt_cde_msg_type = 'MT103' THEN Select rolbenc.ior_txt_acct_no from ls2user.tls_imt_out_role rolbenc where rolbenc.ior_rid_outgng_imt = imt.imt_rid_imt_out and rolbenc.ior_cde_swft_rtyp = 'BENCR'
WHEN imt.imt_cde_msg_type = 'MT202'
THEN '') as BeneficiaryCustomerAccount,
...
FROM
...
WHERE
...