Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command based on parameter 2

Status
Not open for further replies.

kristal9

Programmer
Feb 15, 2007
95
0
0
US
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?
 
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.
 
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.
 
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
 
thank you both! I really appreciate your time and help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top