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!

how to add parameter where the hardcoded column

Rajesh123Aug 14 2018 — edited Aug 14 2018

Hi All,

I have data with 2 UNION clauses , 1st one is Approved status, 2nd one is Pending status with hard coded.

I want to add parameter on class_status.

if i pass Approved populate only Approved , if i pass Pending populate only Pending ,

else populate NULL class_status rows.

with

table_x

as(

select 'Viswa Abc' vendor_name, 1111 vendor_num, 'Approved' class_status from dual

union all

select 'AAA Translation, Inc.' vendor_name, 2222 vendor_num, 'Approved' class_status from dual

union all

select 'Achieve Unite' vendor_name, 3333 vendor_num, null class_status from dual

union all

select 'Agile Big Picture' vendor_name, 4444 vendor_num, null class_status from dual

),

table_y

as(

select 'Alert Logic, Inc' vendor_name, 5555 vendor_num, 'Pending' class_status from dual

union all

select 'Amy Minniear'     vendor_name, 6666 vendor_num, 'Pending' class_status from dual

union all

select 'Becky Kent'       vendor_name, 7777 vendor_num, 'Pending' class_status from dual

)

select * from table_x

where class_status='Approved'

and class_status=:p_class

union

select * from table_y

where class_status='Pending'

and class_status=:p_class

This post has been answered by Frank Kulash on Aug 14 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 11 2018
Added on Aug 14 2018
18 comments
1,151 views