DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: AD Hoc SQL Parameter

  1. #1
    Join Date
    Mar 2004
    Posts
    55

    AD Hoc SQL Parameter

    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

  2. #2
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    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.
    Cheers!
    OraKid.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width