Click to See Complete Forum and Search --> : AD Hoc SQL Parameter


mozart
09-07-2004, 03:33 AM
i know that passing parameters in a query would look somethig like this

select * from atlast where city=:city

However how do i pass a parameter that is ad hoc or not compulsory. In other words if I don't care about city i can ignore it and it returns all records

May seem simple but need help

balajiyes
09-07-2004, 03:59 AM
A simple, stupid way of doing it would be:
select * from atlast where city=NVL(:city, city)
In this case, you are assuming that if the bind variable is NULL, you need all the rows.

A second approach would be to use dynamic SQL.

HTH.