Prompt user to enter single, multiple or all values in Oracle Select query

喜夏-厌秋 提交于 2020-01-24 21:08:12

问题


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)   

来源:https://stackoverflow.com/questions/40456230/prompt-user-to-enter-single-multiple-or-all-values-in-oracle-select-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!