From 2e88e639cac120d5443d63ce45d9975b72e16caf Mon Sep 17 00:00:00 2001 From: hardya Date: Tue, 18 Dec 2007 17:13:38 +0000 Subject: [PATCH] Add views of COSTS table, include effectivity details. git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3017 248e525c-4dfb-0310-94bc-949c084e9493 --- Schema/V_AICO.vw | 25 +++++++++++++++++++++++++ Schema/V_BACO.vw | 25 +++++++++++++++++++++++++ Schema/V_HOCO.vw | 25 +++++++++++++++++++++++++ Schema/V_MECO.vw | 25 +++++++++++++++++++++++++ Schema/V_MOCO.vw | 25 +++++++++++++++++++++++++ Schema/mipViews.sql | 7 ++++++- 6 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 Schema/V_AICO.vw create mode 100644 Schema/V_BACO.vw create mode 100644 Schema/V_HOCO.vw create mode 100644 Schema/V_MECO.vw create mode 100644 Schema/V_MOCO.vw diff --git a/Schema/V_AICO.vw b/Schema/V_AICO.vw new file mode 100644 index 0000000..10c22f0 --- /dev/null +++ b/Schema/V_AICO.vw @@ -0,0 +1,25 @@ +CREATE OR REPLACE VIEW V_AICO AS +SELECT aico_code + ,description + ,selling_price + ,cost_price + ,delivery_cost + ,regi_code + ,valid_from AS effective_from + ,least(nvl(valid_to + ,to_date('2099' + ,'yyyy')) + ,nvl(next_valid_from + ,to_date('2099' + ,'yyyy'))) AS effective_to + FROM (SELECT aico_code + ,description + ,selling_price + ,cost_price + ,delivery_cost + ,regi_code + ,valid_from + ,valid_to + ,lead(valid_from) over(PARTITION BY cost.AICO_code, regi_code ORDER BY valid_from) AS next_valid_from + FROM costs cost + WHERE cost_type = 'AICO') diff --git a/Schema/V_BACO.vw b/Schema/V_BACO.vw new file mode 100644 index 0000000..c154984 --- /dev/null +++ b/Schema/V_BACO.vw @@ -0,0 +1,25 @@ +CREATE OR REPLACE VIEW V_BACO AS +SELECT bas_code + ,description + ,selling_price + ,cost_price + ,delivery_cost + ,regi_code + ,valid_from AS effective_from + ,least(nvl(valid_to + ,to_date('2099' + ,'yyyy')) + ,nvl(next_valid_from + ,to_date('2099' + ,'yyyy'))) AS effective_to + FROM (SELECT bas_code + ,description + ,selling_price + ,cost_price + ,delivery_cost + ,regi_code + ,valid_from + ,valid_to + ,lead(valid_from) over(PARTITION BY cost.bas_code, regi_code ORDER BY valid_from) AS next_valid_from + FROM costs cost + WHERE cost_type = 'BACO'); diff --git a/Schema/V_HOCO.vw b/Schema/V_HOCO.vw new file mode 100644 index 0000000..6cdab91 --- /dev/null +++ b/Schema/V_HOCO.vw @@ -0,0 +1,25 @@ +CREATE OR REPLACE VIEW V_HOCO AS +SELECT hou_code + ,description + ,selling_price + ,cost_price + ,delivery_cost + ,regi_code + ,valid_from AS effective_from + ,least(nvl(valid_to + ,to_date('2099' + ,'yyyy')) + ,nvl(next_valid_from + ,to_date('2099' + ,'yyyy'))) AS effective_to + FROM (SELECT hou_code + ,description + ,selling_price + ,cost_price + ,delivery_cost + ,regi_code + ,valid_from + ,valid_to + ,lead(valid_from) over(PARTITION BY cost.hou_code, regi_code ORDER BY valid_from) AS next_valid_from + FROM costs cost + WHERE cost_type = 'HOCO'); diff --git a/Schema/V_MECO.vw b/Schema/V_MECO.vw new file mode 100644 index 0000000..cae346e --- /dev/null +++ b/Schema/V_MECO.vw @@ -0,0 +1,25 @@ +CREATE OR REPLACE VIEW V_MECO AS +SELECT metr_code + ,description + ,selling_price + ,cost_price + ,delivery_cost + ,regi_code + ,valid_from AS effective_from + ,least(nvl(valid_to + ,to_date('2099' + ,'yyyy')) + ,nvl(next_valid_from + ,to_date('2099' + ,'yyyy'))) AS effective_to + FROM (SELECT metr_code + ,description + ,selling_price + ,cost_price + ,delivery_cost + ,regi_code + ,valid_from + ,valid_to + ,lead(valid_from) over(PARTITION BY cost.metr_code, regi_code ORDER BY valid_from) AS next_valid_from + FROM costs cost + WHERE cost_type = 'MECO'); diff --git a/Schema/V_MOCO.vw b/Schema/V_MOCO.vw new file mode 100644 index 0000000..e9ec4f4 --- /dev/null +++ b/Schema/V_MOCO.vw @@ -0,0 +1,25 @@ +CREATE OR REPLACE VIEW V_MOCO AS +SELECT modu_code + ,description + ,selling_price + ,cost_price + ,delivery_cost + ,regi_code + ,valid_from AS effective_from + ,least(nvl(valid_to + ,to_date('2099' + ,'yyyy')) + ,nvl(next_valid_from + ,to_date('2099' + ,'yyyy'))) AS effective_to + FROM (SELECT modu_code + ,description + ,selling_price + ,cost_price + ,delivery_cost + ,regi_code + ,valid_from + ,valid_to + ,lead(valid_from) over(PARTITION BY cost.modu_code, regi_code ORDER BY valid_from) AS next_valid_from + FROM costs cost + WHERE cost_type = 'MOCO') moco; diff --git a/Schema/mipViews.sql b/Schema/mipViews.sql index 1a7db7c..f758c48 100644 --- a/Schema/mipViews.sql +++ b/Schema/mipViews.sql @@ -5,4 +5,9 @@ @@v_enquiry_prty_supp.vw @@V_LAST_ENQUIRY_UPDATE.vw @@V_PRTY_ID_FOR_ENQUIRIES.vw -@@v_party_addresses.vw \ No newline at end of file +@@v_party_addresses.vw +@@V_MOCO.vw +@@V_MECO.vw +@@V_HOCO.vw +@@V_BACO.vw +@@V_AICO.vw