1
votes

I tried researching this but am a little stuck. I need to prompt a user to enter a value (single, multiple or all) for a report that only takes a "Select" statement from Oracle. For example, user can enter a store# as "07" (single value), "07", "08" (as multiple values ), or a result bringing back all store#'s. I had the following below, but unfortunately it does not work in the program we are using from our company as every prompt field is mandatory in their program so my sql below won't work. I need something where there is 1 prompt parameter where the user can enter one store, multiple stores or all stores are returned. Any help would be appreciated.

 select d.sale_date,d.slip_no,d.extension_amount
 from sale_details d
 where 
 ('&ALL_SITES'='Y' or (site_id='&SITE_ID1' and '&ALL_SITES' is null) and 
 union all
 select d.sale_date,d.slip_no,d.extension_amount 
 from sale_details d
 where
 (site_id='&SITE_ID2' and '&ALL_SITES' is null)   
Are you trying to build a SQL*Plus script? Or are you trying to build a stored procedure that will be called from some application? You seem to be talking about an application but your code is apparently using SQL*Plus substitution variables. - Justin Cave
It is just strictly SQL, I can't use a stored procedure in the program. Unfortunately it can only be a select statement. - user1941350
Are you saying that you're building a SQL*Plus script? Substitution variables, which you appear to be using here, are not part of the SQL language. They are something that a client application like SQL*Plus may use (though most clients won't support substitution variables). - Justin Cave
Yes, it is just a small script using SQL*Plus, I am thinking I might be able to call a procedure through a select statement, I will try this also. - user1941350
You can call a function (assuming it does not change database state) in a select statement but not a procedure. - Justin Cave