f



conditional selection of 'AND' or 'Select' in Oracle

I am working on Oracle reports . One of the parameters that a User
inputs is
'report_type'. Now, is there a way to do the following within a SQL
query with no use of procedures or functions.

select blaa from foo where 

something = something
// if report_type='some_data' then
and somethingelse = something else
//else do nothing


Also, IS there a way of doing something like the following

// if report_type='some_data' then

     select blaa from foo where 
      something = something
    // if report_type='some_data' then
       and somethingelse = something else
      //else do nothing

else
      select blass1 from foo where
      something = something
    // if report_type='some_data' then
        and somethingelse = something else
    //else do nothing
0
rohit_reborn
4/16/2004 11:45:51 PM
comp.databases.oracle.tools 4963 articles. 0 followers. art (172) is leader. Post Follow

2 Replies
482 Views

Similar Articles

[PageSpeed] 50

"Rohit Dhawan" <rohit_reborn@yahoo.com> wrote in message
news:c76d1c78.0404161545.550a50cb@posting.google.com...
| I am working on Oracle reports . One of the parameters that a User
| inputs is
| 'report_type'. Now, is there a way to do the following within a SQL
| query with no use of procedures or functions.
|
| select blaa from foo where
|
| something = something
| // if report_type='some_data' then
| and somethingelse = something else
| //else do nothing
|
|
| Also, IS there a way of doing something like the following
|
| // if report_type='some_data' then
|
|      select blaa from foo where
|       something = something
|     // if report_type='some_data' then
|        and somethingelse = something else
|       //else do nothing
|
| else
|       select blass1 from foo where
|       something = something
|     // if report_type='some_data' then
|         and somethingelse = something else
|     //else do nothing


couldn't quite follow all your pseudo code, but it looks like you might want
to look into the case statement -- depending on the version of oracle you're
running

;-{ mcs


0
Mark
4/17/2004 1:57:27 AM
"Rohit Dhawan" <rohit_reborn@yahoo.com> schrieb im Newsbeitrag
news:c76d1c78.0404161545.550a50cb@posting.google.com...
> I am working on Oracle reports . One of the parameters that a User
> inputs is
> 'report_type'. Now, is there a way to do the following within a SQL
> query with no use of procedures or functions.
>
> select blaa from foo where
>
> something = something
> // if report_type='some_data' then
> and somethingelse = something else
> //else do nothing
>
>
> Also, IS there a way of doing something like the following
>
> // if report_type='some_data' then
>
>      select blaa from foo where
>       something = something
>     // if report_type='some_data' then
>        and somethingelse = something else
>       //else do nothing
>
> else
>       select blass1 from foo where
>       something = something
>     // if report_type='some_data' then
>         and somethingelse = something else
>     //else do nothing

Try something like this:

1. Query:
- Make a placeholder qp_where_condition
- and then transform your query:

select blah
from blubb
&qp_where_condition


2. Before Report Trigger:

bunch of code...
....
IF condition1 THEN --Also You may use CASE ...
   :qp_where := 'WHERE something = a and so on'
ELSE ...
.... more code ...


hth, Jan


0
Jan
4/19/2004 6:22:19 AM
Reply: