DECODE Komutunu kullanırken aşağidaki gibi yazarsanız hem daha okunaklı olacak hemde geliştirmeniz kolay olacaktir.
decode ( :message_type
, 'NEWBUY', 'NEWBUY'
, 'REPAIR', 'REPAIR'
, 'NEWBUY,REPAIR', ( SELECT MIN (MESSAGE_TYPE)
FROM xxrb_requisitions_in_stage
WHERE MESSAGE_TYPE IN ('NEWBUY', 'REPAIR')
)
);
yada message_type degerini where koşulu ile şartlayabilirsiniz.
SELECT *
FROM xxrb_requisitions_in_stage
WHERE MESSAGE_TYPE IN DECODE (:MESSAGE_TYPE,
'NEWBUY', 'NEWBUY',
'REPAIR', 'REPAIR',
'NEWBUY,REPAIR', MESSAGE_TYPE
)
AND MESSAGE_TYPE IN ('NEWBUY', 'REPAIR')
hic decode kullanmayıp bunun yerine message_type ı LIKE KOMUTU ile de sorgulayabilir
WHERE :message_type LIKE '%' || message_type || '%'
WHERE ',' || :message_type || ',' LIKE '%,' || message_type || ',%'
////////////////////////////////////////////////////////////////////////////////////////
WHERE CASE
WHEN :message_type = message_type
THEN 'Okay'
WHEN :message_type = 'NEWBUY,REPAIR'
AND message_type IN ('NEWBUY', 'REPAIR')
THEN 'Okay'
END = 'Okay'
No comments:
Post a Comment