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!

dynamic column selection in where clause

998879Mar 25 2013 — edited Mar 26 2013
Hi All,

I want to select one or more columns in where clause of sql based on user input.

There are 5 columns in the DB for flag. let's say BG1, BG2, BG3, BG4, BG5.

below is the sample data.

ID Name BG1 BG2 BG3 BG4 BG5
1 abc Y N Y N Y
2 def N Y Y N N
3 ghi Y Y Y Y N
4 mno Y Y Y Y Y

Now user want to select columns dynamically at run time. He can select multiple values. For example if he select BG1 and BG4 then query output should be as below.

ID Name BG1 BG2 BG3 BG4 BG5
1 abc Y N Y N Y
3 ghi Y Y Y Y N
4 mno Y Y Y Y Y

Thanks in advance.

Regards,
Rakesh
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 23 2013
Added on Mar 25 2013
4 comments
1,839 views