Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This has been the MOST helpful forum that I have been a part of and I want to say thank you. The tips, tricks and helpful advice that you all contribute to have been lifesavers in many instances..."

Geography

Where in the world do Tek-Tips members come from?
kristal9 (Programmer)
9 May 12 12:56
Hi,
Oracle, CR2008

I would like to set up a parameter "Week/Month" where it would prompt the user to select the value of either "Week" or "Month" and based on his selection, the report will return data from either the Week Fact Table or the Month Fact Table. There are no other tables involved.

I was attempting to do this with a command but not having much luck with it. the parameter within a command seems to be retricted to be used in the where clause.

Suggestions?  
Helpful Member!  hilfy ( IS/IT--Management)
9 May 12 14:04
I would include both tables in your query and do something like this:

CODE

Select
  dim_detail.Name,
  decode({?Week/Month}, 'Week', week_fact.value, month_fact.value)
from dim_detail
  left join week_fact
    on week_fact.ID = dim_detail.ID
      and {?Week/Month} = 'Week'
  left join month_fact
    on month_fact.ID = dim_detail.ID
      and {?Week/Month} = 'Month'

This format uses your parameter to determine which table to pull the data from and, while both fact tables are in the joins, only the one that matches the parameter will actually pull data.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.

kristal9 (Programmer)
9 May 12 15:38
Thanks Hilfy for your response... I have applied this but am getting an error message in syntax where it's not recognizing dim_detail.

I don't have any DIM tables in my database. I have only one or the other FACT table. is the "dim_detail.Name,  decode({?Week/Month}, 'Week', week_fact.value, month_fact.value)" part of your code creating it from the parameter?

please let me know.

the as I have written it is:

CODE

Select  
    dim_detail.id,  decode({?Week/Month}, 'Week', Fact_Week.Week_SID, Fac_Month.Month_SID)
from dim_detail  
    left join FACT_Week  
        on MTRC Fact_Week.Week_SID = dim_detail.ID      
        and {?Week/Month} = 'Week'  
    left join Fac_Month
        on Fac_Month.Month_SID = dim_detail.ID     
        and {?Week/Month} = 'Month'


appreciate your time and patience.
 
Helpful Member!  lbass (TechnicalUser)
9 May 12 21:21
Try setting it up like this:

select Fact_Week.field1,Fact_Week.field2
from Fact_Week
where '{?Week/Month}'='Week'
union all
select Fac_Month.field1, Fac_Month.field2
from Fac_Month
where '{?Week/Month}'='Month'

Note you have to use single quotes around string parameters within the command.

-LB
kristal9 (Programmer)
10 May 12 14:08

thank you both! I really appreciate your time and help.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close