dbTalk Databases Forums  

Pass variable into View?

comp.databases.oracle comp.databases.oracle


Discuss Pass variable into View? in the comp.databases.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mark
 
Posts: n/a

Default Pass variable into View? - 07-19-2004 , 11:11 AM






Hi,

I'm trying to write a view that returns a historical view of records
as of a certain date. The records come from a live and historical
table and I need to return the records as they were in the live table
on various dates. The SQL to do this is no problem but it requires a
date value in a where clause in an inner select (the sql is below for
reference - the date value that needs to be variable is hardcoded as
'01/01/2001'). Can I somehow pass this into a view or is a view the
correct approach?

Thanks,
Mark

CREATE OR REPLACE VIEW CGPPR_GLOBAL_FPS_AT_DATE ( GLOBAL_FP_ID,
GLOBAL_FP_PRICE, GLOBAL_FP_COMMENT, GLOBAL_FP_TBU, GLOBAL_FP_DISC_CAT,
GLOBAL_FP_VOL_DISC, GLOBAL_FP_PARTNER_PRICE, GLOBAL_FP_LIST_PRICE,
GLOBAL_FP_MSCAT, GLOBAL_FP_WPCAT, GLOBAL_FP_EFF_DATE,
GLOBAL_FP_MOD_WHO, GLOBAL_FP_MOD_DATE )
AS
Select tblA.* From (
Select GLOBAL_FP_ID, GLOBAL_FP_PRICE, GLOBAL_FP_COMMENT,
GLOBAL_FP_TBU, GLOBAL_FP_DISC_CAT, GLOBAL_FP_VOL_DISC,
GLOBAL_FP_PARTNER_PRICE, GLOBAL_FP_LIST_PRICE, GLOBAL_FP_MSCAT,
GLOBAL_FP_WPCAT, GLOBAL_FP_EFF_DATE, GLOBAL_FP_MOD_WHO,
GLOBAL_FP_MOD_DATE
From cgppr_global_fps
UNION ALL
Select GLOBAL_FP_ID, GLOBAL_FP_PRICE, GLOBAL_FP_COMMENT,
GLOBAL_FP_TBU, GLOBAL_FP_DISC_CAT, GLOBAL_FP_VOL_DISC,
GLOBAL_FP_PARTNER_PRICE, GLOBAL_FP_LIST_PRICE, GLOBAL_FP_MSCAT,
GLOBAL_FP_WPCAT, GLOBAL_FP_EFF_DATE, GLOBAL_FP_MOD_WHO,
GLOBAL_FP_MOD_DATE
From cgppr_global_fps
) tblA,
(
Select GLOBAL_FP_ID, Max(GLOBAL_FP_MOD_DATE) GLOBAL_FP_MOD_DATE
From
(
Select GLOBAL_FP_ID, GLOBAL_FP_MOD_DATE
From cgppr_global_fps
UNION
Select GLOBAL_FP_ID, GLOBAL_FP_MOD_DATE
From cgppr_h_global_fps
)
Where GLOBAL_FP_MOD_DATE < to_date('01/01/2001', 'dd/mm/YY')
Group By GLOBAL_FP_ID
) tblB
Where tblA.GLOBAL_FP_ID = tblB.GLOBAL_FP_ID
And tblA.GLOBAL_FP_MOD_DATE = tblB.GLOBAL_FP_MOD_DATE
WITH READ ONLY;

Reply With Quote
  #2  
Old   
Wit Serdakovskij
 
Posts: n/a

Default Re: Pass variable into View? - 07-19-2004 , 02:40 PM






Hello, Mark,

near 09:11 19-Jul from zzzzzz45 (AT) hotmail (DOT) com:

Quote:
Hi,

I'm trying to write a view that returns a historical view of records
as of a certain date. The records come from a live and historical
table and I need to return the records as they were in the live table
on various dates. The SQL to do this is no problem but it requires a
date value in a where clause in an inner select (the sql is below for
reference - the date value that needs to be variable is hardcoded as
'01/01/2001'). Can I somehow pass this into a view or is a view the
correct approach?
Try to use package variable (or user-defined function) in view. Set the
value before using view.

Quote:
Thanks,
Mark
[...]

--
wbr,
Wit.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.