Scd type 1 using pl-sql
Hello
I am writing a pl-sql which will perform SCD type 1.
The Type 1 methodology overwrites old data with new data, and therefore does not track historical data at all. This is most appropriate when correcting certain types of data errors, such as the spelling of a name. (Assuming you won't ever need to know how it used to be misspelled in the past.)
Another example would be of a database table that keeps supplier information.
Supplier_key Supplier_Name Supplier_State
001 Phlogistical Supply Company CA
so hence I created two tables
create table ssn_load1
( ssn number(10,0),
credit_score number(6,0));
create table ssn_load2
( ssn number(10,0),
credit_score number(6,0));
and the target table
create table ssn_target
( sq_id number(8,0) primary key,
ssn number(10,0),
credit_score number(6,0));
since I want sq_id as auto incremented,I have created a following trigger
CREATE SEQUENCE test_sequence
START WITH 1
INCREMENT BY 1;
CREATE OR REPLACE TRIGGER test_trigger
BEFORE INSERT
ON ssn_target
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT test_sequence.nextval INTO :NEW.SQ_ID FROM dual;
END;
Now inoder to perform type 1 I have followed a following thing
YOu have source table
tbl1(col1, col2, col3) - where col1 is the key and (col2, col3) are the attributes
target table
tbl2(col21, col22) - where (col21, col21) are the attributes
do this join for change data capture
select <col list>,
case when col22 is null and col23 is null then 'NEW'
when col2 = col22 and col3 = col23 then 'NO CHANGE'
else 'MODIFIED' end
from
tbl1 LEFT OUTER JOIN tbl2
ON tbl1.col1 = tbl2.col21
following is my pl-sql ,but I dont know how to write insert update statement in the switch case.
declare
cursor ssn1
is select from ssn_load1;*
for row in ssn1 loop
select s2.ssn,s2.credit_score from ssn_load2 s2 left outer join ssn_load1 s1 on s1.ssn=s2.ssn;
* SWITCH (ssn)*
* DO*
CASE 'Insert':if s2.ssn!=s1.ssn
Insert into ssn_target(ssn,credit_score)values();
CASE 'No Change':
CASE 'Modify':Update ssn_target set
DEFAULT:
DO END;
end loop;
END;
please help me how to proceed from here
will be waiting for reply
Thank You!!
Isn't this a MERGE?
In the outer join approach, it might be simpler to do the join in the cursor and keep the PL/SQL simple. I didn't really understand your three-table scenario though.
Similar Messages
-
Creating an SCD Type 2 in T SQL without using MERGE
I am attempting to create an SCD type 2 using T-SQL without MERGE (I'm not allowed to use it as a condition of the development work I am doing). I can use a CTE, but I have not tried that yet.
I have a temp table that contains ten records that I am testing with. The following is one variant of the code I have used to try and make this work:
declare
@System_User nchar(50)
,@CurrentDate datetime
,@MaxCheckDate datetime
set @System_User = system_user
set @CurrentDate = getdate()
--INSERT
insert dim.slot
Source_Slot_ID
,Slot_Start_DateTime
,Patients_PerSlot
,IsSlotSearchable
,IsSlotVisible
,[Created_Date]
,[Created_By]
select
src.IdSlot
,src.SlotDateTime
,src.PatientsPerSlot
,src.IsSlotSearchable
,src.IsSlotVisible
,@CurrentDate
,@System_User
from #TmepSlot src
left join dim.Slot dest
on src.IdSlot = dest.Source_Slot_ID
left join (select source_slot_id, max(created_date) as created_date from dim.slot group by Source_Slot_ID) MaxRecord
on dest.Source_Slot_ID = MaxRecord.Source_Slot_ID
and dest.Created_Date = MaxRecord.created_date
where dest.Source_Slot_ID is null
or
src.PatientsPerSlot
<> dest.Patients_PerSlot
or
src.IsSlotSearchable <> dest.IsSlotSearchable
or
src.IsSlotVisible
<> dest.IsSlotVisible
The problem with this variation is that when I change a value in the source like src.Patients_PerSlot, and then run the query, I get the new record i expect, but when I run the query again, a duplicate record gets created.
How do I correctly isolate the correct latest record and add the changed record without inserting that changed record more than once?
Thank you for your help.
cdun2Hi,
shouldn't you use an inner join between dest and maxrecord like so:
from #TmepSlot src
left join (dim.Slot dest
inner join (select source_slot_id, max(created_date) as created_date from dim.slot group by Source_Slot_ID) MaxRecord
on dest.Source_Slot_ID = MaxRecord.Source_Slot_ID
and dest.Created_Date = MaxRecord.created_date)
on src.IdSlot = dest.Source_Slot_ID
where dest.Source_Slot_ID is null
regards,
Rudolf
Rudolf Swiers
Thanks! I don't remember when I've done a join that way, but it makes sense.
cdun2 -
Error in merge statement when trying to impliment SCD type 2 using merge...
Hi ,
I'm trying to impliment SCD type 2 using Merge using below blog as reference but sime how it is erroring out with error
http://www.made2mentor.com/2013/08/how-to-load-slowly-changing-dimensions-using-t-sql-merge/
Msg 207, Level 16, State 1, Line 40
Invalid column name 'Current'.
Msg 207, Level 16, State 1, Line 38
Invalid column name 'Current'.
Msg 207, Level 16, State 1, Line 47
Invalid column name 'Current'.
Here is the code below...
--Create Temporaty table to hold dimension records
IF OBJECT_ID('tempdb..#DimVirtualQueue') IS NOT NULL
DROP TABLE #DimVirtualQueue;
CREATE TABLE #DimVirtualQueue
( [VQ_name] [varchar](50) NULL,
[contact_type] [varchar](50) NULL,
[center_node_id] [int] NULL,
[sed_id] [datetime] NULL,
[eed_id] [datetime] NULL,
[insert_date] [datetime] NULL,
[Current] [char](1) NOT NULL
INSERT INTO #DimVirtualQueue(VQ_name, contact_type, center_node_id, sed_id, eed_id, insert_date,[Current] )
SELECT VQ_name, contact_type, center_node_id, sed_id , eed_id,GETDATE(),'Y'
FROM
( --Declare Source and Target tables.
MERGE dbo.tblSwDM_dim_VQ_test AS TARGET
--Source
USING (SELECT
RTRIM(LTRIM(Stage.RESOURCE_NAME)) AS VQ_name,
'Unknown' AS contact_type,
0 AS center_node_id,
CONVERT(INT,CONVERT(VARCHAR(8),GMT_START_TIME,112)) AS sed_id,
CONVERT(INT,CONVERT(VARCHAR(8),ISNULL(GMT_END_TIME,'2070-01-01'),112)) AS eed_id,
GETDATE() AS insert_date
FROM dbo.tblGenesys_stg_RESOURCE_ Stage
WHERE resource_type = 'queue'
AND resource_subtype = 'VirtualQueue'
AND NOT EXISTS (SELECT 1 FROM dbo.tblSwDM_dim_VQ AS dim
WHERE RTRIM(LTRIM(stage.RESOURCE_NAME)) = RTRIM(LTRIM(dim.vq_name))) ) SOURCE
ON TARGET.VQ_name = SOURCE.VQ_name
WHEN NOT MATCHED BY TARGET
THEN
INSERT ( VQ_name, contact_type, center_node_id, sed_id, eed_id, insert_date,[Current] )
VALUES (SOURCE.VQ_name,SOURCE.contact_type,SOURCE.center_node_id,SOURCE.sed_id,SOURCE.eed_id,SOURCE.insert_date,'Y')
WHEN MATCHED AND TARGET.[Current] = 'Y'
AND EXISTS (
SELECT SOURCE.VQ_name
EXCEPT
SELECT TARGET.VQ_name
--Expire the records in target if exist in source.
THEN UPDATE SET TARGET.[Current] = 'N',
TARGET.[eed_id] = SOURCE.eed_id
OUTPUT $Action ActionOut, SOURCE.VQ_name,SOURCE.contact_type,SOURCE.center_node_id,SOURCE.sed_id,SOURCE.eed_id) AS MergeOut
WHERE MergeOut.ActionOut = 'UPDATE';
--Insert data into dimension
INSERT tblSwDM_dim_VQ_test
SELECT VQ_name,contact_type,center_node_id,sed_id,eed_id,insert_date,[Current] FROM #DimVirtualQueue
Any help to resolve issue is appreciated...
Thanks,
Vishal..You need to show the DDL of your target table: dbo.tblSwDM_dim_VQ_test.
Do you have a column named [Current] in this table? -
Has anyone ever implemented SCD Type-4 using SSIS??
Hello Experts!!
I have been trying to implement SCD TYPE-4 using SSIS and really got stuck and searched on-line for help. for my surprise, there isn't anything up on this topic.
I know the theory behind SCD Type-4 is to maintain history in seperate tables in a rapid changing dimensions.
please help if any of you ever implemented scd type-4 using SSIS.Hi,
The stock Slowly Changing Dimension Transformation of SSIS only supports SCD Type 1 and Type 2. For SCD Type 4, it maintains two tables: one to keep the current data, and the other one to keep the historical data. As a workaround, you can also implement
SCD Type 1 via SCD Transformation, and implement Change Data Capture at the same time. SSIS also provides CDC Control Task and related Data Flow components.
References:
http://www.bidn.com/blogs/TomLannen/bidn-blog/2606/slowly-changing-dimension-type-1-changes-using-ssis-scd-component
http://www.mattmasson.com/2011/12/cdc-in-ssis-for-sql-server-2012-2/
Regards,
Mike Yin
TechNet Community Support -
Hi ,
I'm trying to impliment SCD type 2 using Merge but unlike typical Merge where you have target and source table, my Inserts come from one table and updates/changes are determined from another table.. I have issue with updates.
below is structure of three tables :
Dimension Table :
VQ_id, VQ_name,
contact_type, center_node_id,
sed_id, eed_id,
IsCurrent, insert_date
VQ_Id is dimension ID based on which Inserts and undates are determined.
VQ_Name : type 1 change
Contact_type , Center_node_ID : type 2 changes
is Current : flag
sed_id , eed_id are start and end effective date ID's
Insert table :
VQ_id,VQ_Name ,Contact_Type , Center_node_ID , Sed_id , eed_id , Insert_date
from the above table, based on VQ_ID , new records are determined .
Updates/history records :
Type 2 changes are tracked based on below table..
VQ_ID, contact_type,
center_node_id, Start_Effective_Date,
CT_ID, Submit_Date
Based on VQ_ID , contact_type, center_node_id,
Start_Effective_Date , end effective date are determined.
Any help in this regard is appreciated...
Thanks ,
Vishal.-- This is dimension table
CREATE TABLE [dbo].[tblSwDM_dim_VQ](
[VQ_dim_id] [int] IDENTITY(1,1) NOT NULL,
[VQ_id] [int] NOT NULL,
[VQ_name] [varchar](50) NOT NULL,
[contact_type] [varchar](50) NULL,
[center_node_id] [int] NULL,
[sed_id] [int] NULL,
[eed_id] [int] NULL,
[IsCurrent] [bit] NOT NULL,
[insert_date] [datetime] NULL,
[Start_Effective_Date] AS (CONVERT([datetime],CONVERT([varchar](8),[sed_id],(0)),(0))),
[End_Effective_Date] AS (CONVERT([datetime],CONVERT([varchar](8),[eed_id],(0)),(0))),
CONSTRAINT [Pk_tblswDM_dim_VQ] PRIMARY KEY CLUSTERED
[VQ_dim_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
-- THis ifrom where updates/type2 changes would be loaded
CREATE TABLE [dbo].[tblSwDM_stg_change_control_next_gen](
[row_id] [int] IDENTITY(1,1) NOT NULL,
[VQ_id] [int] NOT NULL,
[contact_type] [varchar](50) NOT NULL,
[center_node_id] [int] NOT NULL,
[Start_Effective_Date] [datetime] NOT NULL,
[CT_ID] [int] NULL,
[Submit_Date] [datetime] NOT NULL,
[isValid] [bit] NULL,
[Remarks] [varchar](100) NULL
) ON [PRIMARY]
Example...
for a Record in dimention table... [dbo].[tblSwDM_dim_VQ]
Before Updates :
VQ_dim_id VQ_id VQ_name contact_type center_node_id sed_id eed_id IsCurrent insert_date Start_Effective_Date End_Effective_Date
2203 376946 Fraud_Span_Det_VQ RFD USCC Detection 4536 20131018 20700101 1 2014-03-21 12:02:42.750 2013-10-18 00:00:00.000 2070-01-01 00:00:00.000
Final Result :
VQ_dim_id VQ_id VQ_name contact_type center_node_id sed_id eed_id IsCurrent insert_date Start_Effective_Date End_Effective_Date
2203 376946 Fraud_Span_Det_VQ RFD USCC Detection 4536 20131018 20140423 0 2014-03-21 12:02:42.750 2013-10-18 00:00:00.000 2014-04-23 00:00:00.000
2605 376946 Fraud_Span_Det_VQ RFS USCC Spanish 4537 20140424 20700101 1 2014-05-07 11:51:00.543 2014-04-24 00:00:00.000 2070-01-01 00:00:00.000 -
Implimenting SCD Type 2 using SQL Merge
Hello ,
I'm working on implimenting SCD type 2 to keep track of changes in dim_A with fields as
Table A
VQ_dim_Id , VQ_Name, Contact_Type , Contact_Type, Center_Node_Id , Sed_id , Eed_Id , Insert_date, IsCurrent
Table B
CT_Number, Virtual_Queue , Center_Node_ID , Center, Contact_Type.
Table B acts as source to determine changes for Updates and inserts for Table A . with join condition on VQ_Name and Virtual_Queue ( Which is bad but business rules have no way to determined by ID)
my quesiton is I can update VQ_Name , Contact_Type , Center_Node_Id from Source (table B) , Is there any best practice in place where I can insert EED_Id, SED_id as well in case they are missing in the source... any code snippet to impliment SCD with this
kinda functionality helpful !
Thank you ,
Vishal.You can use
WHEN NOT MATCHED THEN
INSERT .......
A best example for SCD type 2 Merge join can be found here...
http://www.mssqltips.com/sqlservertip/2883/using-the-sql-server-merge-statement-to-process-type-2-slowly-changing-dimensions/
Please mark as answer, if this post helped you solve the issue.
Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles. -
Insertion / Update of field of type "TIME" using Native SQL
Hi ABAP gurus,
We are trying to perform inserts and updates within an ORACLE table where a TIME field exists without suscess. We are trying to code it using Native SQL.
EXEC SQL.
INSERT INTO table (field1[name], field2[age], field3[birthday], field4[hour])
VALUES (:name, :age, TO_DATE(:date_birth), ¿:hour?)
ENDEXEC.
EXEC SQL.
UPDATE table SET field3[birthday] = TO_DATE(:date_birth), field4[hour] = ¿:hour?
WHERE field1[name] = :name AND field2[age] = :age
ENDEXEC.
Which is the right coding sentence in order to achieve our goal?
Many thanks in advance. Best regards,
Imanol>
Imanol Beguiristain wrote:
> Hi all,
>
> I am sorry for being unclear.
>
> I do want to code both INSERT and UPDATE. That is clear.
>
> The problem we are having is that we don't know how to code (using Native SQL) such instructions using in the SQL sentence a field of TIME type.
>
> Any helps?
>
> Thanks in advance.
>
> Imanol
I've not heard of an Oracle TIME datatype; we used to use the timestamp which is stored as part of the date or we set up a separate column to hold the time defined as CHAR. Still, it is possible that they have created such a thing since I last did SQL. In which case, there would have to be a function like TO_DATE which you would use to convert your time to its time format.
If you mean TIMESTAMP you can use something like the following to do the data conversion.
TO_TIMESTAMP(LOCALTIMESTAMP, 'DD-MON-RR HH.MI.SSXFF') -
SCD's implemention using T-SQL version 2005 (with out merge)
Business logic:
--we are quarterly updating data on table with respective of cus_ID’s
--for your info, in a quarter Cus_ID transaction >80, then cus_ID is valid (pass)..in EXCEL extract date is nothing but every quarter starting date.
Need to implement below logic:
Quarter 1:
1. Loaded 3 records in to the table in first quarter (1/1/2015), here cus_id(21) failed due to less transactions
Quarter 2:
We are again reran the data on the table. cus_id(21) passed so here we want to maintain old record history (21 failed and also 21 passed)and new inserted record. As well as have to update old record To_date (new record from date -1 day)
Same thing applied for quarter 3 and quarter 4
for your reference,
Thanks & Regards,Are you using BIDS? Or just T_SQL? If the former, use the SCD transformation, if the latter, please post:
1. CREATE TABLE statements so we can see the schema of your tables
2. INSERT INTO statements with sample data to populate the tables from step 1.
3. THe query you have at the moment, so we can see where you work is at.
4. the desired results, using a complete, correct query -
Anybody got SCD Type 2's to perform quickly using dimension operator
Hi there,
Hitting major performance problems running mappings to populate SCD Type 2's when they have large amounts of pre-existing data.
Anybody got this performing acceptably? Tried indexing but to no avail.
Many ThanksHi there,
Thanks for getting back to me - found the patch and this patch hasd already been applied.
An example of the sql being generated in a really simple mapping with the dimension operator for small tables is as follows
MERGE
/*+ APPEND PARALLEL("NS_0") */
INTO
"RETAILER_PUBLISHER_NS"
USING
(SELECT
"MERGE_DELTA_ROW_0"."NS_OUTLET_SRC_ID$1" "NS_OUTLET_SRC_ID",
"MERGE_DELTA_ROW_0"."NS_PUBLISHER_CODE$1" "NS_PUBLISHER_CODE",
"MERGE_DELTA_ROW_0"."NS_TITLE_CLASSIFICATION_CODE$1" "NS_TITLE_CLASSIFICATION_CODE",
"MERGE_DELTA_ROW_0"."NS_SUPPLY_FLAG$1" "NS_SUPPLY_FLAG",
"MERGE_DELTA_ROW_0"."NS_EFF_DATE$1" "NS_EFF_DATE",
"MERGE_DELTA_ROW_0"."NS_EXP_DATE$1" "NS_EXP_DATE",
"MERGE_DELTA_ROW_0"."NS_ID$1" "NS_ID"
FROM
(SELECT
"NS_ID" "NS_ID$1",
"NS_OUTLET_SRC_ID" "NS_OUTLET_SRC_ID$1",
"NS_PUBLISHER_CODE" "NS_PUBLISHER_CODE$1",
"NS_TITLE_CLASSIFICATION_CODE" "NS_TITLE_CLASSIFICATION_CODE$1",
"NS_SUPPLY_FLAG" "NS_SUPPLY_FLAG$1",
"NS_EFF_DATE" "NS_EFF_DATE$1",
"NS_EXP_DATE" "NS_EXP_DATE$1"
FROM
(SELECT
(Case When (("SPLITTER_INPUT_SUBQUERY"."NS_ID_0_0" IS NULL) OR ((("SPLITTER_INPUT_SUBQUERY"."NS_EXP_DATE_0_0" IS NULL AND TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_0_0", 'J.HH24.MI.SS') <= TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1", 'J.HH24.MI.SS')) OR ("SPLITTER_INPUT_SUBQUERY"."NS_EXP_DATE_0_0" IS NOT NULL AND TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_0_0", 'J.HH24.MI.SS') <= TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1", 'J.HH24.MI.SS') AND TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EXP_DATE_0_0", 'J.HH24.MI.SS') >= TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1", 'J.HH24.MI.SS'))) AND (("SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_1" IS NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_2" IS NOT NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_1" IS NOT NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_2" IS NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_1" != "SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_2") OR ("SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_1" IS NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_0_0" IS NOT NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_1" IS NOT NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_0_0" IS NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_1" != "SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_0_0")))) then ("SPLITTER_INPUT_SUBQUERY"."NS_ID_1") else ("SPLITTER_INPUT_SUBQUERY"."NS_ID_0_0") end)/* MERGE_DELTA_ROW.OUTGRP1.NS_ID */ "NS_ID",
"SPLITTER_INPUT_SUBQUERY"."NS_OUTLET_SRC_ID_1"/* MERGE_DELTA_ROW.OUTGRP1.NS_OUTLET_SRC_ID */ "NS_OUTLET_SRC_ID",
"SPLITTER_INPUT_SUBQUERY"."NS_PUBLISHER_CODE_1"/* MERGE_DELTA_ROW.OUTGRP1.NS_PUBLISHER_CODE */ "NS_PUBLISHER_CODE",
"SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_1"/* MERGE_DELTA_ROW.OUTGRP1.NS_TITLE_CLASSIFICATION_CODE */ "NS_TITLE_CLASSIFICATION_CODE",
"SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_1"/* MERGE_DELTA_ROW.OUTGRP1.NS_SUPPLY_FLAG */ "NS_SUPPLY_FLAG",
(Case When (("SPLITTER_INPUT_SUBQUERY"."NS_ID_0_0" IS NULL)) then ((case when ("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1" < SYSDATE ) then ("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1") else ( SYSDATE ) end)) when ((("SPLITTER_INPUT_SUBQUERY"."NS_EXP_DATE_0_0" IS NULL AND TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_0_0", 'J.HH24.MI.SS') <= TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1", 'J.HH24.MI.SS')) OR ("SPLITTER_INPUT_SUBQUERY"."NS_EXP_DATE_0_0" IS NOT NULL AND TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_0_0", 'J.HH24.MI.SS') <= TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1", 'J.HH24.MI.SS') AND TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EXP_DATE_0_0", 'J.HH24.MI.SS') >= TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1", 'J.HH24.MI.SS'))) AND (("SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_1" IS NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_2" IS NOT NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_1" IS NOT NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_2" IS NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_1" != "SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_2") OR ("SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_1" IS NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_0_0" IS NOT NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_1" IS NOT NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_0_0" IS NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_1" != "SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_0_0"))) then ("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1") else ("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_0_0") end)/* MERGE_DELTA_ROW.OUTGRP1.NS_EFF_DATE */ "NS_EFF_DATE",
(Case When ((ROW_NUMBER() OVER (PARTITION BY "SPLITTER_INPUT_SUBQUERY"."NS_OUTLET_SRC_ID_1","SPLITTER_INPUT_SUBQUERY"."NS_PUBLISHER_CODE_1" ORDER BY "SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1" DESC)) = 1) then (Case When (("SPLITTER_INPUT_SUBQUERY"."NS_ID_0_0" IS NULL) OR ((("SPLITTER_INPUT_SUBQUERY"."NS_EXP_DATE_0_0" IS NULL AND TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_0_0", 'J.HH24.MI.SS') <= TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1", 'J.HH24.MI.SS')) OR ("SPLITTER_INPUT_SUBQUERY"."NS_EXP_DATE_0_0" IS NOT NULL AND TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_0_0", 'J.HH24.MI.SS') <= TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1", 'J.HH24.MI.SS') AND TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EXP_DATE_0_0", 'J.HH24.MI.SS') >= TO_CHAR("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1", 'J.HH24.MI.SS'))) AND (("SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_1" IS NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_2" IS NOT NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_1" IS NOT NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_2" IS NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_1" != "SPLITTER_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CO_2") OR ("SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_1" IS NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_0_0" IS NOT NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_1" IS NOT NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_0_0" IS NULL) OR ("SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_1" != "SPLITTER_INPUT_SUBQUERY"."NS_SUPPLY_FLAG_0_0")))) then ( TO_DATE('31-DEC-4000') ) else ("SPLITTER_INPUT_SUBQUERY"."NS_EXP_DATE_0_0") end) else (("SPLITTER_INPUT_SUBQUERY"."NS_EFF_DATE_1" - INTERVAL '1' SECOND)) end)/* MERGE_DELTA_ROW.OUTGRP1.NS_EXP_DATE */ "NS_EXP_DATE"
FROM
(SELECT
"INGRP1"."NS_ID" "NS_ID_1",
"INGRP1"."NS_OUTLET_SRC_ID" "NS_OUTLET_SRC_ID_1",
"INGRP1"."NS_PUBLISHER_CODE" "NS_PUBLISHER_CODE_1",
"INGRP1"."NS_TITLE_CLASSIFICATION_CODE" "NS_TITLE_CLASSIFICATION_CO_1",
"INGRP1"."NS_SUPPLY_FLAG" "NS_SUPPLY_FLAG_1",
"INGRP1"."NS_EFF_DATE" "NS_EFF_DATE_1",
"INGRP1"."NS_EXP_DATE" "NS_EXP_DATE_1",
"INGRP2"."NS_ID" "NS_ID_0_0",
"INGRP2"."NS_OUTLET_SRC_ID" "NS_OUTLET_SRC_ID_0_0",
"INGRP2"."NS_PUBLISHER_CODE" "NS_PUBLISHER_CODE_0_0",
"INGRP2"."NS_TITLE_CLASSIFICATION_CODE" "NS_TITLE_CLASSIFICATION_CO_2",
"INGRP2"."NS_SUPPLY_FLAG" "NS_SUPPLY_FLAG_0_0",
"INGRP2"."NS_EFF_DATE" "NS_EFF_DATE_0_0",
"INGRP2"."NS_EXP_DATE" "NS_EXP_DATE_0_0",
"INGRP2"."DIMENSION_KEY" "DIMENSION_KEY_0"
FROM
( SELECT
"RETAILER_PUBLISHER_NS"."NS_ID" "NS_ID",
"RETAILER_PUBLISHER_NS"."NS_OUTLET_SRC_ID" "NS_OUTLET_SRC_ID",
"RETAILER_PUBLISHER_NS"."NS_PUBLISHER_CODE" "NS_PUBLISHER_CODE",
"RETAILER_PUBLISHER_NS"."NS_TITLE_CLASSIFICATION_CODE" "NS_TITLE_CLASSIFICATION_CODE",
"RETAILER_PUBLISHER_NS"."NS_SUPPLY_FLAG" "NS_SUPPLY_FLAG",
"RETAILER_PUBLISHER_NS"."NS_EFF_DATE" "NS_EFF_DATE",
"RETAILER_PUBLISHER_NS"."NS_EXP_DATE" "NS_EXP_DATE",
"RETAILER_PUBLISHER_NS"."DIMENSION_KEY" "DIMENSION_KEY"
FROM
"RETAILER_PUBLISHER_NS" "RETAILER_PUBLISHER_NS"
WHERE
( "RETAILER_PUBLISHER_NS"."DIMENSION_KEY" = "RETAILER_PUBLISHER_NS"."NS_ID" ) AND
( "RETAILER_PUBLISHER_NS"."NS_ID" IS NOT NULL ) ) "INGRP2"
RIGHT OUTER JOIN ( SELECT
NULL "NS_ID",
"LOOKUP_INPUT_SUBQUERY"."NS_OUTLET_SRC_ID$2" "NS_OUTLET_SRC_ID",
"LOOKUP_INPUT_SUBQUERY"."NS_PUBLISHER_CODE$2" "NS_PUBLISHER_CODE",
"LOOKUP_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CODE$2" "NS_TITLE_CLASSIFICATION_CODE",
"LOOKUP_INPUT_SUBQUERY"."NS_SUPPLY_FLAG$2" "NS_SUPPLY_FLAG",
"LOOKUP_INPUT_SUBQUERY"."NS_EFF_DATE$2" "NS_EFF_DATE",
"LOOKUP_INPUT_SUBQUERY"."NS_EXP_DATE$2" "NS_EXP_DATE"
FROM
(SELECT
"DEDUP_SRC"."NS_ID$3" "NS_ID$2",
"DEDUP_SRC"."NS_OUTLET_SRC_ID$3" "NS_OUTLET_SRC_ID$2",
"DEDUP_SRC"."NS_PUBLISHER_CODE$3" "NS_PUBLISHER_CODE$2",
"DEDUP_SRC"."NS_TITLE_CLASSIFICATION_CODE$3" "NS_TITLE_CLASSIFICATION_CODE$2",
"DEDUP_SRC"."NS_SUPPLY_FLAG$3" "NS_SUPPLY_FLAG$2",
"DEDUP_SRC"."NS_EFF_DATE$3" "NS_EFF_DATE$2",
"DEDUP_SRC"."NS_EXP_DATE$3" "NS_EXP_DATE$2"
FROM
(SELECT
NULL/* DEDUP_SRC.OUTGRP1.NS_ID */ "NS_ID$3",
("PUB_AGENT_MATRIX_CC"."PAM_CUSTOMER_ID"/* EXPR_SRC.OUTGRP1.NS_OUTLET_SRC_ID */)/* DEDUP_SRC.OUTGRP1.NS_OUTLET_SRC_ID */ "NS_OUTLET_SRC_ID$3",
((to_char("PUB_AGENT_MATRIX_CC"."PAM_PUBLISHER_CODE")/* EXP.OUTGRP1.PAM_PUBLISHER_CODE */)/* EXPR_SRC.OUTGRP1.NS_PUBLISHER_CODE */)/* DEDUP_SRC.OUTGRP1.NS_PUBLISHER_CODE */ "NS_PUBLISHER_CODE$3",
("PUB_AGENT_MATRIX_CC"."PAM_TITLCLAS_CODE"/* EXPR_SRC.OUTGRP1.NS_TITLE_CLASSIFICATION_CODE */)/* DEDUP_SRC.OUTGRP1.NS_TITLE_CLASSIFICATION_CODE */ "NS_TITLE_CLASSIFICATION_CODE$3",
("PUB_AGENT_MATRIX_CC"."PAM_SUPPLY_FLAG"/* EXPR_SRC.OUTGRP1.NS_SUPPLY_FLAG */)/* DEDUP_SRC.OUTGRP1.NS_SUPPLY_FLAG */ "NS_SUPPLY_FLAG$3",
MIN(("PUB_AGENT_MATRIX_CC"."PAM_EFFECTIVE_DATE"/* EXPR_SRC.OUTGRP1.NS_EFF_DATE */)) KEEP (DENSE_RANK FIRST ORDER BY NULL/* EXPR_SRC.OUTGRP1.NS_ID */)/* DEDUP_SRC.OUTGRP1.NS_EFF_DATE */ "NS_EFF_DATE$3",
NULL/* DEDUP_SRC.OUTGRP1.NS_EXP_DATE */ "NS_EXP_DATE$3"
FROM
"REFSTG"."PUB_AGENT_MATRIX_CC" "PUB_AGENT_MATRIX_CC"
WHERE
( "PUB_AGENT_MATRIX_CC"."PAM_ADD_REMOVE_FLAG" = 'A' )
GROUP BY
("PUB_AGENT_MATRIX_CC"."PAM_CUSTOMER_ID"/* EXPR_SRC.OUTGRP1.NS_OUTLET_SRC_ID */), ((to_char("PUB_AGENT_MATRIX_CC"."PAM_PUBLISHER_CODE")/* EXP.OUTGRP1.PAM_PUBLISHER_CODE */)/* EXPR_SRC.OUTGRP1.NS_PUBLISHER_CODE */), ("PUB_AGENT_MATRIX_CC"."PAM_TITLCLAS_CODE"/* EXPR_SRC.OUTGRP1.NS_TITLE_CLASSIFICATION_CODE */), ("PUB_AGENT_MATRIX_CC"."PAM_SUPPLY_FLAG"/* EXPR_SRC.OUTGRP1.NS_SUPPLY_FLAG */),NULL,NULL/* RETAILER_PUBLISHER_NS.DEDUP_SRC */) "DEDUP_SRC") "LOOKUP_INPUT_SUBQUERY"
WHERE
( NOT ( "LOOKUP_INPUT_SUBQUERY"."NS_OUTLET_SRC_ID$2" IS NULL AND "LOOKUP_INPUT_SUBQUERY"."NS_PUBLISHER_CODE$2" IS NULL ) ) ) "INGRP1" ON ( ( ( "INGRP2"."NS_EFF_DATE" IS NULL OR ( ( "INGRP2"."NS_EXP_DATE" IS NULL AND TO_CHAR ( "INGRP2"."NS_EFF_DATE" , 'J.HH24.MI.SS' ) <= TO_CHAR ( "INGRP1"."NS_EFF_DATE" , 'J.HH24.MI.SS' ) ) OR ( "INGRP2"."NS_EXP_DATE" IS NOT NULL AND TO_CHAR ( "INGRP2"."NS_EFF_DATE" , 'J.HH24.MI.SS' ) <= TO_CHAR ( "INGRP1"."NS_EFF_DATE" , 'J.HH24.MI.SS' ) AND TO_CHAR ( "INGRP2"."NS_EXP_DATE" , 'J.HH24.MI.SS' ) >= TO_CHAR ( "INGRP1"."NS_EFF_DATE" , 'J.HH24.MI.SS' ) ) ) ) ) AND ( ( "INGRP2"."NS_PUBLISHER_CODE" = "INGRP1"."NS_PUBLISHER_CODE" ) ) AND ( ( "INGRP2"."NS_OUTLET_SRC_ID" = "INGRP1"."NS_OUTLET_SRC_ID" ) ) )) "SPLITTER_INPUT_SUBQUERY"
WHERE
( ( ( "SPLITTER_INPUT_SUBQUERY"."NS_OUTLET_SRC_ID_1" = "SPLITTER_INPUT_SUBQUERY"."NS_OUTLET_SRC_ID_0_0" AND "SPLITTER_INPUT_SUBQUERY"."NS_PUBLISHER_CODE_1" = "SPLITTER_INPUT_SUBQUERY"."NS_PUBLISHER_CODE_0_0" ) ) OR ( "SPLITTER_INPUT_SUBQUERY"."NS_OUTLET_SRC_ID_0_0" IS NULL AND "SPLITTER_INPUT_SUBQUERY"."NS_PUBLISHER_CODE_0_0" IS NULL ) )
UNION
SELECT
"DEDUP_SCD_SRC"."NS_ID$4" "NS_ID",
"DEDUP_SCD_SRC"."NS_OUTLET_SRC_ID$4" "NS_OUTLET_SRC_ID",
"DEDUP_SCD_SRC"."NS_PUBLISHER_CODE$4" "NS_PUBLISHER_CODE",
"DEDUP_SCD_SRC"."NS_TITLE_CLASSIFICATION_CODE$4" "NS_TITLE_CLASSIFICATION_CODE",
"DEDUP_SCD_SRC"."NS_SUPPLY_FLAG$4" "NS_SUPPLY_FLAG",
"DEDUP_SCD_SRC"."NS_EFF_DATE$4" "NS_EFF_DATE",
"DEDUP_SCD_SRC"."NS_EXP_DATE$4" "NS_EXP_DATE"
FROM
(SELECT
"AGG_INPUT"."NS_ID$5"/* DEDUP_SCD_SRC.OUTGRP1.NS_ID */ "NS_ID$4",
"AGG_INPUT"."NS_OUTLET_SRC_ID$5"/* DEDUP_SCD_SRC.OUTGRP1.NS_OUTLET_SRC_ID */ "NS_OUTLET_SRC_ID$4",
"AGG_INPUT"."NS_PUBLISHER_CODE$5"/* DEDUP_SCD_SRC.OUTGRP1.NS_PUBLISHER_CODE */ "NS_PUBLISHER_CODE$4",
MIN("AGG_INPUT"."NS_TITLE_CLASSIFICATION_CODE$5") KEEP (DENSE_RANK FIRST ORDER BY "AGG_INPUT"."NS_TITLE_CLASSIFICATION_CODE$5" NULLS LAST)/* DEDUP_SCD_SRC.OUTGRP1.NS_TITLE_CLASSIFICATION_CODE */ "NS_TITLE_CLASSIFICATION_CODE$4",
MIN("AGG_INPUT"."NS_SUPPLY_FLAG$5") KEEP (DENSE_RANK FIRST ORDER BY "AGG_INPUT"."NS_SUPPLY_FLAG$5" NULLS LAST)/* DEDUP_SCD_SRC.OUTGRP1.NS_SUPPLY_FLAG */ "NS_SUPPLY_FLAG$4",
MIN("AGG_INPUT"."NS_EFF_DATE$5") KEEP (DENSE_RANK FIRST ORDER BY "AGG_INPUT"."NS_EFF_DATE$5" NULLS LAST)/* DEDUP_SCD_SRC.OUTGRP1.NS_EFF_DATE */ "NS_EFF_DATE$4",
MIN("AGG_INPUT"."NS_EXP_DATE$5") KEEP (DENSE_RANK FIRST ORDER BY "AGG_INPUT"."NS_EXP_DATE$5" NULLS LAST)/* DEDUP_SCD_SRC.OUTGRP1.NS_EXP_DATE */ "NS_EXP_DATE$4"
FROM
(SELECT
"SPLITTER_INPUT_SUBQUERY$1"."NS_ID_0_0$1"/* UPDATE_DELTA_ROW.OUTGRP1.NS_ID */ "NS_ID$5",
"SPLITTER_INPUT_SUBQUERY$1"."NS_OUTLET_SRC_ID_1$1"/* UPDATE_DELTA_ROW.OUTGRP1.NS_OUTLET_SRC_ID */ "NS_OUTLET_SRC_ID$5",
"SPLITTER_INPUT_SUBQUERY$1"."NS_PUBLISHER_CODE_1$1"/* UPDATE_DELTA_ROW.OUTGRP1.NS_PUBLISHER_CODE */ "NS_PUBLISHER_CODE$5",
"SPLITTER_INPUT_SUBQUERY$1"."NS_TITLE_CLASSIFICATION_CO_2$1"/* UPDATE_DELTA_ROW.OUTGRP1.NS_TITLE_CLASSIFICATION_CODE */ "NS_TITLE_CLASSIFICATION_CODE$5",
"SPLITTER_INPUT_SUBQUERY$1"."NS_SUPPLY_FLAG_0_0$1"/* UPDATE_DELTA_ROW.OUTGRP1.NS_SUPPLY_FLAG */ "NS_SUPPLY_FLAG$5",
"SPLITTER_INPUT_SUBQUERY$1"."NS_EFF_DATE_0_0$1"/* UPDATE_DELTA_ROW.OUTGRP1.NS_EFF_DATE */ "NS_EFF_DATE$5",
("SPLITTER_INPUT_SUBQUERY$1"."NS_EFF_DATE_1$1" - INTERVAL '1' SECOND)/* UPDATE_DELTA_ROW.OUTGRP1.NS_EXP_DATE */ "NS_EXP_DATE$5"
FROM
(SELECT
"INGRP1"."NS_ID" "NS_ID_1$1",
"INGRP1"."NS_OUTLET_SRC_ID" "NS_OUTLET_SRC_ID_1$1",
"INGRP1"."NS_PUBLISHER_CODE" "NS_PUBLISHER_CODE_1$1",
"INGRP1"."NS_TITLE_CLASSIFICATION_CODE" "NS_TITLE_CLASSIFICATION_CO_1$1",
"INGRP1"."NS_SUPPLY_FLAG" "NS_SUPPLY_FLAG_1$1",
"INGRP1"."NS_EFF_DATE" "NS_EFF_DATE_1$1",
"INGRP1"."NS_EXP_DATE" "NS_EXP_DATE_1$1",
"INGRP2"."NS_ID" "NS_ID_0_0$1",
"INGRP2"."NS_OUTLET_SRC_ID" "NS_OUTLET_SRC_ID_0_0$1",
"INGRP2"."NS_PUBLISHER_CODE" "NS_PUBLISHER_CODE_0_0$1",
"INGRP2"."NS_TITLE_CLASSIFICATION_CODE" "NS_TITLE_CLASSIFICATION_CO_2$1",
"INGRP2"."NS_SUPPLY_FLAG" "NS_SUPPLY_FLAG_0_0$1",
"INGRP2"."NS_EFF_DATE" "NS_EFF_DATE_0_0$1",
"INGRP2"."NS_EXP_DATE" "NS_EXP_DATE_0_0$1",
"INGRP2"."DIMENSION_KEY" "DIMENSION_KEY_0$1"
FROM
( SELECT
"RETAILER_PUBLISHER_NS"."NS_ID" "NS_ID",
"RETAILER_PUBLISHER_NS"."NS_OUTLET_SRC_ID" "NS_OUTLET_SRC_ID",
"RETAILER_PUBLISHER_NS"."NS_PUBLISHER_CODE" "NS_PUBLISHER_CODE",
"RETAILER_PUBLISHER_NS"."NS_TITLE_CLASSIFICATION_CODE" "NS_TITLE_CLASSIFICATION_CODE",
"RETAILER_PUBLISHER_NS"."NS_SUPPLY_FLAG" "NS_SUPPLY_FLAG",
"RETAILER_PUBLISHER_NS"."NS_EFF_DATE" "NS_EFF_DATE",
"RETAILER_PUBLISHER_NS"."NS_EXP_DATE" "NS_EXP_DATE",
"RETAILER_PUBLISHER_NS"."DIMENSION_KEY" "DIMENSION_KEY"
FROM
"RETAILER_PUBLISHER_NS" "RETAILER_PUBLISHER_NS"
WHERE
( "RETAILER_PUBLISHER_NS"."DIMENSION_KEY" = "RETAILER_PUBLISHER_NS"."NS_ID" ) AND
( "RETAILER_PUBLISHER_NS"."NS_ID" IS NOT NULL ) ) "INGRP2"
RIGHT OUTER JOIN ( SELECT
NULL "NS_ID",
"LOOKUP_INPUT_SUBQUERY"."NS_OUTLET_SRC_ID$2" "NS_OUTLET_SRC_ID",
"LOOKUP_INPUT_SUBQUERY"."NS_PUBLISHER_CODE$2" "NS_PUBLISHER_CODE",
"LOOKUP_INPUT_SUBQUERY"."NS_TITLE_CLASSIFICATION_CODE$2" "NS_TITLE_CLASSIFICATION_CODE",
"LOOKUP_INPUT_SUBQUERY"."NS_SUPPLY_FLAG$2" "NS_SUPPLY_FLAG",
"LOOKUP_INPUT_SUBQUERY"."NS_EFF_DATE$2" "NS_EFF_DATE",
"LOOKUP_INPUT_SUBQUERY"."NS_EXP_DATE$2" "NS_EXP_DATE"
FROM
(SELECT
"DEDUP_SRC"."NS_ID$3" "NS_ID$2",
"DEDUP_SRC"."NS_OUTLET_SRC_ID$3" "NS_OUTLET_SRC_ID$2",
"DEDUP_SRC"."NS_PUBLISHER_CODE$3" "NS_PUBLISHER_CODE$2",
"DEDUP_SRC"."NS_TITLE_CLASSIFICATION_CODE$3" "NS_TITLE_CLASSIFICATION_CODE$2",
"DEDUP_SRC"."NS_SUPPLY_FLAG$3" "NS_SUPPLY_FLAG$2",
"DEDUP_SRC"."NS_EFF_DATE$3" "NS_EFF_DATE$2",
"DEDUP_SRC"."NS_EXP_DATE$3" "NS_EXP_DATE$2"
FROM
(SELECT
NULL/* DEDUP_SRC.OUTGRP1.NS_ID */ "NS_ID$3",
("PUB_AGENT_MATRIX_CC"."PAM_CUSTOMER_ID"/* EXPR_SRC.OUTGRP1.NS_OUTLET_SRC_ID */)/* DEDUP_SRC.OUTGRP1.NS_OUTLET_SRC_ID */ "NS_OUTLET_SRC_ID$3",
((to_char("PUB_AGENT_MATRIX_CC"."PAM_PUBLISHER_CODE")/* EXP.OUTGRP1.PAM_PUBLISHER_CODE */)/* EXPR_SRC.OUTGRP1.NS_PUBLISHER_CODE */)/* DEDUP_SRC.OUTGRP1.NS_PUBLISHER_CODE */ "NS_PUBLISHER_CODE$3",
("PUB_AGENT_MATRIX_CC"."PAM_TITLCLAS_CODE"/* EXPR_SRC.OUTGRP1.NS_TITLE_CLASSIFICATION_CODE */)/* DEDUP_SRC.OUTGRP1.NS_TITLE_CLASSIFICATION_CODE */ "NS_TITLE_CLASSIFICATION_CODE$3",
("PUB_AGENT_MATRIX_CC"."PAM_SUPPLY_FLAG"/* EXPR_SRC.OUTGRP1.NS_SUPPLY_FLAG */)/* DEDUP_SRC.OUTGRP1.NS_SUPPLY_FLAG */ "NS_SUPPLY_FLAG$3",
MIN(("PUB_AGENT_MATRIX_CC"."PAM_EFFECTIVE_DATE"/* EXPR_SRC.OUTGRP1.NS_EFF_DATE */)) KEEP (DENSE_RANK FIRST ORDER BY NULL/* EXPR_SRC.OUTGRP1.NS_ID */)/* DEDUP_SRC.OUTGRP1.NS_EFF_DATE */ "NS_EFF_DATE$3",
NULL/* DEDUP_SRC.OUTGRP1.NS_EXP_DATE */ "NS_EXP_DATE$3"
FROM
"REFSTG"."PUB_AGENT_MATRIX_CC" "PUB_AGENT_MATRIX_CC"
WHERE
( "PUB_AGENT_MATRIX_CC"."PAM_ADD_REMOVE_FLAG" = 'A' )
GROUP BY
("PUB_AGENT_MATRIX_CC"."PAM_CUSTOMER_ID"/* EXPR_SRC.OUTGRP1.NS_OUTLET_SRC_ID */), ((to_char("PUB_AGENT_MATRIX_CC"."PAM_PUBLISHER_CODE")/* EXP.OUTGRP1.PAM_PUBLISHER_CODE */)/* EXPR_SRC.OUTGRP1.NS_PUBLISHER_CODE */), ("PUB_AGENT_MATRIX_CC"."PAM_TITLCLAS_CODE"/* EXPR_SRC.OUTGRP1.NS_TITLE_CLASSIFICATION_CODE */), ("PUB_AGENT_MATRIX_CC"."PAM_SUPPLY_FLAG"/* EXPR_SRC.OUTGRP1.NS_SUPPLY_FLAG */),NULL,NULL/* RETAILER_PUBLISHER_NS.DEDUP_SRC */) "DEDUP_SRC") "LOOKUP_INPUT_SUBQUERY"
WHERE
( NOT ( "LOOKUP_INPUT_SUBQUERY"."NS_OUTLET_SRC_ID$2" IS NULL AND "LOOKUP_INPUT_SUBQUERY"."NS_PUBLISHER_CODE$2" IS NULL ) ) ) "INGRP1" ON ( ( ( "INGRP2"."NS_EFF_DATE" IS NULL OR ( ( "INGRP2"."NS_EXP_DATE" IS NULL AND TO_CHAR ( "INGRP2"."NS_EFF_DATE" , 'J.HH24.MI.SS' ) <= TO_CHAR ( "INGRP1"."NS_EFF_DATE" , 'J.HH24.MI.SS' ) ) OR ( "INGRP2"."NS_EXP_DATE" IS NOT NULL AND TO_CHAR ( "INGRP2"."NS_EFF_DATE" , 'J.HH24.MI.SS' ) <= TO_CHAR ( "INGRP1"."NS_EFF_DATE" , 'J.HH24.MI.SS' ) AND TO_CHAR ( "INGRP2"."NS_EXP_DATE" , 'J.HH24.MI.SS' ) >= TO_CHAR ( "INGRP1"."NS_EFF_DATE" , 'J.HH24.MI.SS' ) ) ) ) ) AND ( ( "INGRP2"."NS_PUBLISHER_CODE" = "INGRP1"."NS_PUBLISHER_CODE" ) ) AND ( ( "INGRP2"."NS_OUTLET_SRC_ID" = "INGRP1"."NS_OUTLET_SRC_ID" ) ) )) "SPLITTER_INPUT_SUBQUERY$1"
WHERE
( "SPLITTER_INPUT_SUBQUERY$1"."NS_OUTLET_SRC_ID_1$1" = "SPLITTER_INPUT_SUBQUERY$1"."NS_OUTLET_SRC_ID_0_0$1" AND "SPLITTER_INPUT_SUBQUERY$1"."NS_PUBLISHER_CODE_1$1" = "SPLITTER_INPUT_SUBQUERY$1"."NS_PUBLISHER_CODE_0_0$1" ) AND
( ( "SPLITTER_INPUT_SUBQUERY$1"."NS_EXP_DATE_0_0$1" IS NULL AND TO_CHAR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_EFF_DATE_0_0$1" , 'J.HH24.MI.SS' ) <= TO_CHAR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_EFF_DATE_1$1" , 'J.HH24.MI.SS' ) ) OR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_EXP_DATE_0_0$1" IS NOT NULL AND TO_CHAR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_EFF_DATE_0_0$1" , 'J.HH24.MI.SS' ) <= TO_CHAR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_EFF_DATE_1$1" , 'J.HH24.MI.SS' ) AND TO_CHAR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_EXP_DATE_0_0$1" , 'J.HH24.MI.SS' ) >= TO_CHAR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_EFF_DATE_1$1" , 'J.HH24.MI.SS' ) ) ) AND
( ( "SPLITTER_INPUT_SUBQUERY$1"."NS_TITLE_CLASSIFICATION_CO_1$1" IS NULL AND "SPLITTER_INPUT_SUBQUERY$1"."NS_TITLE_CLASSIFICATION_CO_2$1" IS NOT NULL ) OR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_TITLE_CLASSIFICATION_CO_1$1" IS NOT NULL AND "SPLITTER_INPUT_SUBQUERY$1"."NS_TITLE_CLASSIFICATION_CO_2$1" IS NULL ) OR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_TITLE_CLASSIFICATION_CO_1$1" != "SPLITTER_INPUT_SUBQUERY$1"."NS_TITLE_CLASSIFICATION_CO_2$1" ) OR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_SUPPLY_FLAG_1$1" IS NULL AND "SPLITTER_INPUT_SUBQUERY$1"."NS_SUPPLY_FLAG_0_0$1" IS NOT NULL ) OR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_SUPPLY_FLAG_1$1" IS NOT NULL AND "SPLITTER_INPUT_SUBQUERY$1"."NS_SUPPLY_FLAG_0_0$1" IS NULL ) OR ( "SPLITTER_INPUT_SUBQUERY$1"."NS_SUPPLY_FLAG_1$1" != "SPLITTER_INPUT_SUBQUERY$1"."NS_SUPPLY_FLAG_0_0$1" ) )) "AGG_INPUT"
GROUP BY
"AGG_INPUT"."NS_ID$5", "AGG_INPUT"."NS_OUTLET_SRC_ID$5", "AGG_INPUT"."NS_PUBLISHER_CODE$5"/* RETAILER_PUBLISHER_NS.DEDUP_SCD_SRC */) "DEDUP_SCD_SRC") ) "MERGE_DELTA_ROW_0"
MERGE_SUBQUERY
ON (
"RETAILER_PUBLISHER_NS"."NS_OUTLET_SRC_ID" = "MERGE_SUBQUERY"."NS_OUTLET_SRC_ID" AND
"RETAILER_PUBLISHER_NS"."NS_PUBLISHER_CODE" = "MERGE_SUBQUERY"."NS_PUBLISHER_CODE" AND
"RETAILER_PUBLISHER_NS"."NS_EFF_DATE" = "MERGE_SUBQUERY"."NS_EFF_DATE" AND
"RETAILER_PUBLISHER_NS"."NS_ID" = "MERGE_SUBQUERY"."NS_ID"
WHEN MATCHED THEN
UPDATE
SET
"NS_TITLE_CLASSIFICATION_CODE" = "MERGE_SUBQUERY"."NS_TITLE_CLASSIFICATION_CODE",
"NS_SUPPLY_FLAG" = "MERGE_SUBQUERY"."NS_SUPPLY_FLAG",
"NS_EXP_DATE" = "MERGE_SUBQUERY"."NS_EXP_DATE"
WHEN NOT MATCHED THEN
INSERT
("RETAILER_PUBLISHER_NS"."NS_ID",
"RETAILER_PUBLISHER_NS"."NS_OUTLET_SRC_ID",
"RETAILER_PUBLISHER_NS"."NS_PUBLISHER_CODE",
"RETAILER_PUBLISHER_NS"."NS_TITLE_CLASSIFICATION_CODE",
"RETAILER_PUBLISHER_NS"."NS_SUPPLY_FLAG",
"RETAILER_PUBLISHER_NS"."NS_EFF_DATE",
"RETAILER_PUBLISHER_NS"."NS_EXP_DATE",
"RETAILER_PUBLISHER_NS"."DIMENSION_KEY")
VALUES
("RETAILER_PUBLISHER_NS_SEQ".NEXTVAL,
"MERGE_SUBQUERY"."NS_OUTLET_SRC_ID",
"MERGE_SUBQUERY"."NS_PUBLISHER_CODE",
"MERGE_SUBQUERY"."NS_TITLE_CLASSIFICATION_CODE",
"MERGE_SUBQUERY"."NS_SUPPLY_FLAG",
"MERGE_SUBQUERY"."NS_EFF_DATE",
"MERGE_SUBQUERY"."NS_EXP_DATE",
"RETAILER_PUBLISHER_NS_SEQ".CURRVAL)
Explain plan:
MERGE STATEMENT, GOAL = ALL_ROWS 1412 2 286
MERGE DW RETAILER_PUBLISHER_NS
VIEW DW
SEQUENCE DW RETAILER_PUBLISHER_NS_SEQ
HASH JOIN OUTER 1412 2 256
VIEW DW 940 2 170
SORT UNIQUE 940 2 218
UNION-ALL
WINDOW SORT 470 1 133
FILTER
NESTED LOOPS OUTER 468 1 133
VIEW DW 4 1 65
SORT GROUP BY 4 1 25
TABLE ACCESS FULL REFSTG PUB_AGENT_MATRIX_CC 3 1 25
VIEW SYS 464 1 68
VIEW DW 464 1 68
TABLE ACCESS FULL DW RETAILER_PUBLISHER_NS 464 1 43
VIEW DW 469 1 85
SORT GROUP BY 469 1 90
NESTED LOOPS 468 1 90
VIEW DW 4 1 37
SORT GROUP BY 4 1 25
TABLE ACCESS FULL REFSTG PUB_AGENT_MATRIX_CC 3 1 25
VIEW SYS 464 1 53
VIEW DW 464 1 68
TABLE ACCESS FULL DW RETAILER_PUBLISHER_NS 464 1 43
TABLE ACCESS FULL DW RETAILER_PUBLISHER_NS 467 337417 14508931
Is this similar to the sql generated at your end? Do you use special loading hints, anything specail with indexing - we have tried standard indexing.
Does this look untoward - have you any other suggestions?
Thanks for your interest. -
SQL types over PLSQL types while using Oracle Applications adapter in BPEL
Use SQL types over PL/SQL types while using Oracle Applications adapter
in BPEL/ ESB
This document will be focusing on Oracle Applications adapter. However Database adapter is much like OA adapter (even OA adapter uses DB Adapter), so the readers who are interested to explore DB adapters, can relate things with this document and go further as well.
Some Guidelines for writing PL/SQL APIs for OA Adapter
As we know when we create a partner link from the OA adapter wizard it sometimes writes some wrapper script supportive to the OA Adapter WSDL which contains below
* Object type for PL/SQL RECORD
* Nested table of the given type for PL/SQL TABLE. For example, the nested table of NUMBER.
* INTEGER substituted for PL/SQL BOOLEAN
* Wrapper Script for converting above three set of data types . (PLSQL to SQL and SQL to PLSQL conversion functions)
In runtime this wrapper script for converting PL/SQL to SQL and SQL to PL/SQL is an extra overhead.
So the first advice would be to avoid the use of the below as parameters of PLSQL API being called by OA Adapter.
* PL/SQL RECORD
* PL/SQL TABLE. For example, the nested table of NUMBER.
* PL/SQL BOOLEAN
In other way we can say we should try to use only SQL data types in arguments if we are planning to call any PL/SQL API from the OA Adapter.
If the requirement is to use a table or record uses the Object type. In place of BOOLEAN better to use VARCHAR or INTEGER what ever fulfills your requirement. Following this guideline we can reduce a huge number of Line of codes to be run each time the adapter being called.
Generally, Oracle E-Biz standard APIs use PL/SQL record types and table types so when there is a requirement to call these API’s from OA Adapter (this is a common requirement in development), and if we directly browse the API in OA Adapter Configuration Wizard and create the partner link, again a huge number of code is written by the wizard in the wrapper script (a number of extra mapping of fields which are not being used in the interface).
In this case better would be to create an Object type with only the required fields which are being used in that call and use them as parameters for the PLSQL API.Find the complete document
http://www.4shared.com/file/167171882/29525116/Use_SQL_types_over_PLSQL_types.html -
How to use PL/SQL type table in SQL FROM clause
Hi All,
I have to use a PL/SQL type table in our SQL statement as a table?
I am using the syntax (below) but it gives PL/SQL: ORA-00902: invalid datatype
SELECT ... FROM TABLE(CAST( var_pl/sql_table AS pl/sql_table)) tab WHERE tab.a=1;
Plz reply with an example.
Thanks.. RatanYou don't need a cast!!!
select *
from table ( <nested_table> )
where <condition>Anyway, are you sure that tab.a is a number?
Here follows an example with an useful function
CREATE OR REPLACE
type string_table as table of varchar2(4000)
CREATE OR REPLACE
FUNCTION split_string (
string IN varchar2,
delimiter IN varchar2
) RETURN string_table IS
tab string_table;
pre integer;
post integer;
step integer;
i integer;
BEGIN
pre := 1;
step := length(delimiter);
i := 0;
tab := string_table();
loop
tab.extend;
i := i + 1;
post := instr(string,delimiter,pre);
if ( post = 0 ) then
tab(i) := substr(string,pre);
return tab;
end if;
tab(i) := substr(string,pre,post-pre);
pre := post + step;
end loop;
END;
select * from table (split_string('abc,dfg,hij',','))
Query finished, retrieving results...
COLUMN_VALUE
abc
dfg
hij -
Any tricks to use PL/SQL types in object attributes?
I guess this is a bit of a newbie-question, but I haven't been able to find any workarounds elsewhere, so please bear with me... I'm far from new to object orientation, but I'm rather new to Oracle's object features.
I was wondering if there's some trick you can use to keep references to attributes of PL/SQL types even though they are not allowed in object types (as these are "SQL", yes I do think I understand). I was thinking there might be some way you could cast them to some data type that is supported in SQL and then get them back by the reverse process when you need them in the PL/SQL inside the methods?
In the concrete case, I would like to keep a reference to a utl_smtp connection in my object. It doesn't matter that the reference would be meaningless in other sessions etc. (actually I may not even want to store the objects in any persistent table - it's the polymorphism I'm after):
CREATE OR REPLACE TYPE o_test AS OBJECT (
att1 NUMBER,
att2 sys.utl_smtp.connection
- which of course give me:
LINE/COL ERROR
0/0 PL/SQL: Compilation unit analysis terminated
3/12 PLS-00329: schema-level type has illegal reference to
SYS.UTL_SMTP
The problem becomes rather dull since I can't pass the connection record as a parameter to methods either.
The only workaround I could think of was to keep the connection as a global variable in a PL/SQL package and then get it from there inside the methods. Of course this can be refined using an index by table and some object unique id to support multiple objects with their separate connections. But it still seems rather clumbsy - especially given that what I was looking for was the elegance of polymorphism.
Any tricks I don't know of?
I'm working in Oracle 10gR2.
best regards,
Jakob
Edited by: schmidt on Mar 21, 2011 10:52 PMThe UTL_SMTP Connection record is not too complicated, and can be easily translated into SQL object types. Add a package to aid in conversion between SQL and PLSQL, and voila!
create or replace type o_utl_tcp_connection is object (
remote_host VARCHAR2(255),
remote_port INTEGER,
local_host VARCHAR2(255),
local_port INTEGER,
charset VARCHAR2(30),
newline VARCHAR2(2),
tx_timeout INTEGER,
private_sd INTEGER
define typeOf_SQL_BOOLEAN = 'number'
define SQL_BOOLEAN = '&typeOf_SQL_BOOLEAN(1)'
define SQL_TRUE = 1
define SQL_FALSE = 0
create or replace type o_utl_smtp_connection is object (
host VARCHAR2(255), -- remote host name
port INTEGER, -- remote port number
tx_timeout INTEGER, -- Transfer time out (in seconds)
private_tcp_con o_utl_tcp_connection, -- private, for implementation use
private_state INTEGER, -- private, for implementation use
-- Optionally, encapsulate all UTL_SMTP package calls behind object methods
member procedure open(
self IN OUT NOCOPY o_utl_smtp_connection,
host IN VARCHAR2,
port IN INTEGER DEFAULT 25,
tx_timeout IN INTEGER DEFAULT NULL,
wallet_path IN VARCHAR2 DEFAULT NULL,
wallet_password IN VARCHAR2 DEFAULT NULL,
secure_connection_before_smtp IN &typeOf_SQL_BOOLEAN DEFAULT &SQL_FALSE
member procedure writeData(
self IN OUT NOCOPY o_utl_smtp_connection,
data IN VARCHAR2 CHARACTER SET ANY_CS
create or replace type body o_utl_smtp_connection is
member procedure open(
self IN OUT NOCOPY o_utl_smtp_connection,
host IN VARCHAR2,
port IN INTEGER DEFAULT 25,
tx_timeout IN INTEGER DEFAULT NULL,
wallet_path IN VARCHAR2 DEFAULT NULL,
wallet_password IN VARCHAR2 DEFAULT NULL,
secure_connection_before_smtp IN &typeOf_SQL_BOOLEAN DEFAULT &SQL_FALSE
is
begin
self := SMTP_UTILS.toSqlConnection(SYS.UTL_SMTP.Open_Connection(
host
, port
, tx_timeout
, wallet_path
, wallet_password
, nvl(secure_connection_before_smtp = &SQL_TRUE, false)
end;
member procedure writeData(
self IN OUT NOCOPY o_utl_smtp_connection,
data IN VARCHAR2 CHARACTER SET ANY_CS
is
conn SYS.UTL_SMTP.Connection := SMTP_UTILS.toPlSqlConnection(self);
begin
begin
SYS.UTL_SMTP.Write_Data(conn, data);
self := SMTP_UTILS.toSqlConnection(conn);
exception
when others then
self := SMTP_UTILS.toSqlConnection(conn);
raise;
end;
end;
end;
create or replace type o_test is object (
attr1 number,
attr2 o_utl_smtp_connection,
member procedure doSomethingWithConnection
create or replace package SMTP_UTILS
is
function toPLSQLConnection(aConnection in o_utl_smtp_connection)
return SYS.UTL_SMTP.Connection;
function toSQLConnection(aConnection in SYS.UTL_SMTP.Connection)
return o_utl_smtp_connection;
end;
create or replace package body SMTP_UTILS
is
function toPLSQLConnection(aConnection in o_utl_smtp_connection)
return SYS.UTL_SMTP.Connection
is
result SYS.UTL_SMTP.Connection;
begin
result.host := aConnection.host;
result.port := aConnection.port;
result.tx_timeout := aConnection.tx_timeout;
result.private_state := aConnection.private_state;
result.private_tcp_con.remote_host := aConnection.private_tcp_con.remote_host;
result.private_tcp_con.remote_port := aConnection.private_tcp_con.remote_port;
result.private_tcp_con.local_host := aConnection.private_tcp_con.local_host;
result.private_tcp_con.local_port := aConnection.private_tcp_con.local_port;
result.private_tcp_con.charset := aConnection.private_tcp_con.charset;
result.private_tcp_con.newline := aConnection.private_tcp_con.newline;
result.private_tcp_con.tx_timeout := aConnection.private_tcp_con.tx_timeout;
result.private_tcp_con.private_sd := aConnection.private_tcp_con.private_sd;
return result;
end;
function toSQLConnection(aConnection in SYS.UTL_SMTP.Connection)
return o_utl_smtp_connection
is
result o_utl_smtp_connection;
begin
result.host := aConnection.host;
result.port := aConnection.port;
result.tx_timeout := aConnection.tx_timeout;
result.private_state := aConnection.private_state;
result.private_tcp_con.remote_host := aConnection.private_tcp_con.remote_host;
result.private_tcp_con.remote_port := aConnection.private_tcp_con.remote_port;
result.private_tcp_con.local_host := aConnection.private_tcp_con.local_host;
result.private_tcp_con.local_port := aConnection.private_tcp_con.local_port;
result.private_tcp_con.charset := aConnection.private_tcp_con.charset;
result.private_tcp_con.newline := aConnection.private_tcp_con.newline;
result.private_tcp_con.tx_timeout := aConnection.private_tcp_con.tx_timeout;
result.private_tcp_con.private_sd := aConnection.private_tcp_con.private_sd;
return result;
end;
end;
create or replace type body o_test is
member procedure doSomethingWithConnection
is
begin
-- Make SMTP calls thru connection object methods
self.attr2.open();
end;
end;
/Hope it helps.
Gerard
Edited by: gaverill on May 17, 2011 3:02 PM - formatted code -
Create table dinamically using java sql types?
Hi! I've an application that reads an XML file. This file contains de definitions of some tables, using java sql types. For example:
<dbtable>
<dbtablename>Name of table</dbtablename>
<dbtablefield>
<name>Name of table field</name>
<type>java.sql.Types.VARCHAR</type>
<length>10</lenght>
<canNull>0</canNull>
<isPK>1</isPK>
</dbtablefield>
</dbtable>That's a little example of one table, with one field. Is a java.sql.Types.VARCHAR (or is equivalent in int), which has a size of 10, it cannot be null and is a primary key for the table.
Now, the lenght, null, and primary keys are not problem at all. What I want to know, is how do I create de table using the java.sql.Types. I mean, I don't want to hard code:
String s = "CREATE TABLE name (COLUMN VARCHAR(10)...";Instead, I want to use some "wild cards", as are used in PreparedStatement. The idea of this is that no matter what DB I'm using, I must always be capable of creating the tables not worrying for the DB. I mean, I must be able to create the table in Oracle, SQL Server, DB2, etc., using the same XML and the same java class.
Something like:
String s = "CREATE TABLE name (COLUMN ? (10)...";
someobject.setObject(1,java.sql.Types.VARCHAR);
someobject.execute(); //create tableIs this possible? Or do I have to make a map for each DB?
Thanks a lot for your help! Dukes available!you can provide some fields at runtime..
for example
"CREATE TABLE name (COLUMN" + arg[1] +"(10)..."
here arg is the string array passed into the main. -
Implementing First In First Out Behaviour Using PL/SQL object types
Hi Friends,
I have a Integer Array of type Varray, I want to implement first in first out behaviour using Pl/SQL object type.Please provide me some idea that i can proceed. If you can provide me any sample code or any documentation,i will be very much thankful to you.Eagerly waiting for your reply.
Thanksbasically i have to implement a queue using pl/sql object types to traverse a tree as we can implement stack (LIFO).
I can give an example of Stack implementation...
CREATE or replace TYPE IntArray AS VARRAY(50) OF INTEGER;
CREATE or replace TYPE IntStack_O AS OBJECT (
maximalSize INTEGER
,top INTEGER
,position IntArray
,MEMBER PROCEDURE initialize
,MEMBER FUNCTION full RETURN BOOLEAN
,MEMBER FUNCTION empty RETURN BOOLEAN
,MEMBER FUNCTION getAnzahl RETURN INTEGER
,MEMBER PROCEDURE push (n IN INTEGER)
,MEMBER PROCEDURE pop (n OUT INTEGER)
CREATE or replace TYPE body IntStack_O AS
MEMBER PROCEDURE initialize IS
BEGIN
top := 0;
-- Call Constructor und set element 1 to NULL
position := IntArray(NULL);
maximalSize := position.LIMIT; -- Get Varray Size
position.EXTEND(maximalSize -1, 1); -- copy elements 1 in 2..50
END initialize;
MEMBER FUNCTION full RETURN BOOLEAN IS
BEGIN
RETURN (top = maximalSize); — Return TRUE when Stack is full
END full;
MEMBER FUNCTION empty RETURN BOOLEAN IS
BEGIN
RETURN (top = 0); — Return TRUE when Stack is empty
END empty;
MEMBER FUNCTION getAnzahl RETURN integer IS
BEGIN
RETURN top;
END;
MEMBER PROCEDURE push (n IN INTEGER) IS
BEGIN
IF NOT full
THEN
top := top + 1; — Push Integer onto the stack
position(top) := n;
ELSE
–Stack ist voll!
RAISE_APPLICATION_ERROR(-20101, ‘Error! Stack overflow. ‘
||’limit for stacksize reached.’);
END IF;
END push;
MEMBER PROCEDURE pop (n OUT INTEGER) IS
BEGIN
IF NOT empty
THEN
n := position(top);
top := top -1; — take top element from stack
ELSE
–Stack ist leer!
RAISE_APPLICATION_ERROR(-20102, ‘Error! Stack underflow. ‘
||’stack is empty.’);
END IF;
END pop;
END;
Now if i run this..i will be getting the following output...
DECLARE
stack intstack_o := intstack_o(NULL,NULL,NULL);
a INTEGER;
BEGIN
stack.initialize;
dbms_output.put_line('Anzahl: ' || stack.getAnzahl);
stack.push(1111);
dbms_output.put_line('Anzahl: ' || stack.getAnzahl);
stack.push(1112);
dbms_output.put_line('Anzahl: ' || stack.getAnzahl);
stack.push(1113);
dbms_output.put_line('Anzahl: ' || stack.getAnzahl);
stack.pop(a);
dbms_output.put_line('Anzahl: ' || stack.getAnzahl);
dbms_output.put_line(a);
stack.pop(a);
dbms_output.put_line('Anzahl: ' || stack.getAnzahl);
dbms_output.put_line(a);
stack.pop(a);
dbms_output.put_line('Anzahl: ' || stack.getAnzahl);
dbms_output.put_line(a);
stack.pop(a);
dbms_output.put_line('Anzahl: ' || stack.getAnzahl);
dbms_output.put_line(a);
END;
Output...
Anzahl: 0
Anzahl: 1
Anzahl: 2
Anzahl: 3
Anzahl: 2
1113
Anzahl: 1
1112
Anzahl: 0
1111
Above is the Stack (Last In First Out) Implementations of integer array.Now my Requirement is Queue(First In First Out) Implementation of Integer array. -
Hi,
I'm relatively new to OBIEE and trying to implement slowly changing dimension type 2.-- i.e. to look up the correct record in the customer dimension (A_FICC_ACCOUNT) based on the transaction date in the fact table (A_FICC_PROFITABILITY). The customer dimension has two time stamps (start_effective_date, end_effective_date), where end_effective_date will be set to NULL for the most recent record.
So far I've set this up as a complex join in the physical layer, as follows:
A_FICC_ACCOUNT.ACCOUNT_ID = A_FICC_PROFITABILITY.ACCOUNT_ID
AND
A_FICC_PROFITABILITY.DAYID >= A_FICC_ACCOUNT.START_EFFECTIVE_DATE AND A_FICC_PROFITABILITY.DAYID < A_FICC_ACCOUNT.END_EFFECTIVE_DATE
OR
A_FICC_PROFITABILITY.DAYID >= A_FICC_ACCOUNT.START_EFFECTIVE_DATE AND A_FICC_ACCOUNT.END_EFFECTIVE_DATE IS NULL
When i run a report in Answers, the generated SQL is as follows:
select distinct T2327.YEARCAPTION as c1,
T13994.SHORT_NAME as c2,
T13994.RANK_W12 as c3,
T13994.RANK_W52 as c4,
T2327.YEARID as c5
from
DIM_FICC_ACCOUNT T13994 /* A_FICC_ACCOUNT */ ,
DIM_TIME T2327 /* A_FICC_TIME */ ,
FACT_FICC_PROFITABILITY T13406 /* A_FICC_PROFITABILITY */
where ( T2327.SKEY = T13406.TIME_ID and T13406.ACCOUNT_ID = T13994.ACCOUNT_ID and T13994.SHORT_NAME = 'PETEROLA' and (T13406.DAYID < T13994.END_EFFECTIVE_DATE or T13994.END_EFFECTIVE_DATE is null) and T13406.DAYID >= T13994.START_EFFECTIVE_DATE )
order by c5, c2, c3, c4
Ran directly against the (Oracle) database using an SQL client, it gives meaningful results according to the recorded historical changes in the dimension. (see attached screenshot). In Answers, however, the results are not correct (see attached screenshot).
http://dl.dropbox.com/u/3345113/output.jpg
Any tips as to what might be wrong would be greatly appreciated.
best regards
MagnusMagnus,
As mentioned customer dimension (A_FICC_ACCOUNT) is a SCD type 2, what is the primary key on this table? I don't think it is ACCOUNT_ID alone.
Usually there exists a surrogate key to keep track of any changes, thus it is on this surrogate key a join should exist with a fact table and applying a filter end_effective date is null should produce the correct result.
If the above scenario is not true in your case, do let me know the structure of the customer dimension and fact table (only columns associated with customer dimension), with relation ship information please.
J
-bifacts
http://www.obinotes.com
Maybe you are looking for
-
Variable substitution - Pseudo Path Variable - file adapter
Hello, I am sending an purchase order fro SRM to the file adapter and like to create an filename like purchaseordernumber.xml. Can anyone give me some help because I do not understand the sap help regarding this topic. The XML starts as follows: <?xm
-
Adding field in the standard report
Hi , i have added the one field in the standard transaction VL06 , in the outboud deliveries report according to the Note 605460. I have to add the field in LIPOV structure. after adding that field(include structure), in output i am not getting that
-
How can i add a cost center in Zenworks? I dont want to use the collection data form. I want to add cost center to a dynamic workstation group. Seems impossible. If i add it to a group in Edirectory. Will Zenworks read that attribute?
-
Hi all, In pivot function "in" clause i want to use sql query, because i want to take values dynamically from the table. How can i use, is there any solution for that. Pls help me. mani
-
I'm looking for a technology that will help me create multiple formats of similar data from an SQL database into PDFs. I haven't found a sales rep at Adobe who knows if any of their products can do what I need and they recommended the user-to-user fo