Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

conditional based flag values in oracle sql

mist123Aug 19 2024 — edited Aug 20 2024
-- Default Flag Whcih order_type is having the default flag set put default flag as Y in that order_type line-- 
-- If there is no default then whatever fnd_profile.value('xxc_grp') set up in profile, mark that as default

WITH table_abc 
AS
(
select '1' default_v ,
'C-grp' order_type,
100 org_id
FROM dual
UNION ALL
SELECT '2' default_v ,
'D-grp' order_type,
100 org_id
FROM dual
UNION ALL
SELECT '2' default_v ,
'A-grp' order_type,
200 org_id
FROM dual
UNION ALL
SELECT '2' default_v ,
'D-grp' order_type,
200 org_id
FROM dual
)
SELECT order_type,
org_id ,
CASE
WHEN default_v='1' THEN 'Yes'
WHEN order_type=fnd_profile.value('xxc_grp') THEN 'Yes'
ELSE 'No'
END default_flag
FROM table_abc;

Note: here default_v=1 means considering as DEFAULT set

fnd_profile.value('xxc_grp') has default values either A-grp or C-grp or D-grp,

In this case org_id 200 doesnot have default value '1', 
so mark it default value is whatever is in the profile fnd_profile.value('xxc_grp')

profile fnd_profile.value('xxc_grp') has 'D-grp'
This post has been answered by Frank Kulash on Aug 20 2024
Jump to Answer
Comments
Post Details
Added on Aug 19 2024
11 comments
442 views