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!

adding filter conditions dynamically in WHERE clause -dynamic SQL help

611859Mar 7 2008 — edited Mar 7 2008
Here I have a simple condition but very complicated query. Basically, I have to put a filter condition in my where clause. "Location" comes to the stored procedure as parameter. Plus there are other parameters as well.

If location = "all", I can run the query simply and get the result. But when Location = "CA", which is just a subset of "ALL" then I am having hard time putting one -- AND statement in WHERE clause.

This query is designed for location = 'ALL'

open cv for
'Select col1, col2, col3, Col4
from t1, t2, t3
WHERE condition1
AND condition2
AND condition3'
AND location = location_id --- This should only run if location IS NOT ALL

I have written a dynamic query but it doesn't work for that part. Any ideas will be appreciated. Thanks,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 4 2008
Added on Mar 7 2008
3 comments
2,471 views