473,395 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Pass variable into View?

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;
Jul 19 '05 #1
1 6576
Hello, Mark,

near 09:11 19-Jul from zz******@hotmail.com:
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.
Thanks,
Mark


[...]

--
wbr,
Wit.
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: HH | last post by:
I'm learning to design web applications with php, mysql, and apache from a book. I copied a sample application called guestbook 2000 that came with the CD in the book to my htdocs folder, but...
3
by: Benito | last post by:
Hi Everyone, Is there an easy way that I could pass a filter (variable) unto a view via stored procedures? I would appreciate your suggestions. Benito
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
23
by: John | last post by:
Last year, I remember finding a web page describing how to pass the name of a file to another web page, and have that web page load that image file. Now, I can't find my record of that (it was...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
8
by: Blue Ocean | last post by:
I know this is somewhat dependent on the circumstances, but let me ask anyway. Suppose I have a 100 byte struct or array or something like that. Which would be more efficient? void...
0
by: weiwei | last post by:
Hi; I am having trouble to get variable from grid view. here is my scenario. I want to delete a row in database from web page, in additon, I also want to delete that user's directory in c:drive. ...
1
by: Mark | last post by:
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...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.