Implimenting SCD type 2 without Merge

Hi ,
While using merge for detecting SCD types 1/2 is ideal but I'd like to impliement SCD type 2 without using merge.Can any one post some good blogs/references to acheive it without using merge.
THanks ,
Vishal.

Have a look @ these links please:
sql server 2005 - T-SQL Syntax for SCD Type 2
SSIS - Using Checksum
to Load Data into Slowly Changing Dimensions
sqldevelop.wordpress.com

Similar Messages

  • 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?

  • SCD type 2 using merge

    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.

  • 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.
    cdun2

    Hi,
    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

  • SCD type 2 in OWB 10g R2

    Hello,
    I am trying out the SCD type 2 in OWB 10g R2. I have no hierarchies and hence created a dimension with one level. Apart from three business attributes I have 2 mandatory attributes as "EFFECTIVE_DATE" and "EXPIRY_DATE". I have set one of the business attributes to "Trigger History".
    I have 3000 rows in the source table. There is no transformation. the data is loaded from source to this dimension directly. One business attribute is loaded using a constant.
    When I executed the mapping, all 3000 rows are populated in the target with the expiry date column having null values and current date in the effective date, which is absolutely fine. When I execute the mapping again without changing anything in the source, rows are inserted in to the target with the effective date set to the second run and the expiry date set to previous effective date. As I understand new rows should be inserted only if there is change in the data.
    Please correct me if I am wrong. Please clarify and if my understanding is right where am I doing wrong with OWB?
    Your help is greatly appreciated
    Thanks a lot on advance!
    Regards,
    Maruthi

    Hi Roelant,
    I think it is important to be aware that although Paris - 10gR2 - is not actually buggy (in this respect!), it is really quite idiosyncratic in exactly how it processes SCDs.
    I followed up on your and Mark's comments, and did an in depth analysis of this topic. It is at http://www.donnapkelly.pwp.blueyonder.co.uk/documents/OWB_10gR2_SCD.pdf
    My conclusions are perhaps of interest to anyone considering doing SCD processing with Paris.
    I'll be doing a follow-up this weekend, and publishing a sort of 'how-to-do-it' guide.
    Cheers,
    Donna
    Message was edited to add the words: "in this respect"

  • 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 Thanks

    Hi 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.

  • 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.

  • Creating a SCD type 2

    Hi All,
    Can anyone tell me the procedure to do a SCD type 2 in ODI. Please list me the steps. I tried doing it myself but it seems to be not working. Especially the Sequence generator. The surrogate keys are not getting generated and nor the values getting updated. I tried to look for the solution or examples in the internet but without success.
    Thanks in advance

    For a better performance, you can use a Query transform before Table Comparison, use the primary key fields (that you use inside Table Comparison) in the Order By tab of the Query transform and select the option Sorted input in Table Comparison transform.

  • ODI - SCD Type 2 - Insert new row error

    Hi All,
    For Dimension I have a surrogate key, a natural key, and a column with "overwrite on change", start_date, end_date, current_record_ind. When I run the interface with the default SCD Type 2 for SQl server, this runs fine. But when I change that one column from "overwrite on change" to "insert new row", it fails on the update step. What should I be looking for anf fixing.
    Thanks for your time and help.

    DB: SQL Server 2008.
    IKM = IKM MSSQL Slowly Changing Dimension
    Error Message: ODI-1228 - Incorrect syntax near the keyword from.
    Code: update T
    set
    from database.dbo.Dim_type as T,
    database.dbo.I$_Dim_type as S
    where T.Cd = S.Cd
    and T.Current_rec_ind = 1
    and IND_UPDATE = 'U'
    To overcome the issue, I have commented the update code in the Knowledge module and the insert works, but for this one it is ok, but I have requirements where one column needs to be overwritten and other column changes will require to add a new record. How to handle both?
    Thanks for your time.

  • HT204053 how do i set up different devices on the same apple Id without merging the contacts from the separate phones

    can i set up multiple iphones on the cloud without merging all contacts?

    Not if they are all syncing contacts with the shared account.  You could allow them to merge, then create separate groups for each person's contacts on icloud.com.  Then each person can adjust their settings to only show the group that their contacts belong to and hide the rest.
    Another option is to keep the devices on the same shared primary account, and add different secondary account to each person's devices by going to Setings>Mail,Contacts,Calendars>Add Account>iCloud and enter a separate ID.  Then each person can turn on contacts syncing in their secondary account and leave contacts syncing turned off in the shared primary account (in Settings>iCloud).

  • My wife and I share an account , is there a way to put both our contact lists in our one iCloud account without merging them., My wife and I share an account , is there a way to put both our contact lists in our one iCloud account without merging them.

    My wife and I both have iPhones and we share an apple ID. Is there a way to put both our contact list in the same iCloud without merging the lists.  We want to be able to use the same iCloud account because we share info .

    Welcome to the Apple community.
    No, there is no way of maintaining two separate contact lists with one account. Ideally you should each have your own iCloud account, you can still share your info by allowing each other to log into the other's account as a secondary account at settings >mail, contact, calendars. You can choose which services you choose to share and which you don't. This way you could maintain separate contact lists but still share them.

  • Is it possible to link two or more accounts without merging?

         Is it possible to link two or more accounts without merging? For example: give access for apple id [email protected] (obviously fake and is used by John) to apple id [email protected] (also obviously fake and is used by Rose). This would only allow access from one consenting party to another, for temporary sharing.
         The accounts would be temporarily linked/paired in the same manner as a bluetooth device (device A shows the user a password to input into device B) except John receives password abc123 and Rose receives password xyz789. they exchange passwords and can use this to do multiple things, such as; pool money to buy a game, a movie, or a song album, or they could share an app or two with each other.
         Is there any feature in apple remotely like this in any way? If so please let me know how I can find or use this feature.
         If not, I would recommend implementing this in the future, if not the near future. There are a lot of people that would use it, and it could allow app designers to make more money, because people would be able to buy something by pooling their money. If you think otherwise, ask anybody who lives in an apartment with three other people, because that is the only way they can afford it.

    You cannot merge or link accounts.
    Sorry.
    You can leave feedback for Apple at:  http://www.apple.com/feedback

  • SCD type 2 in OBIEE

    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
    Magnus

    Magnus,
    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

  • 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

Maybe you are looking for

  • Issue on Changing the Payroll Area in Mid of the Month from Biweekly to Mon

    Dear Experts, I have an issue on payroll area which is changing from biweekly to monthly in Mid of the Month. One employee was retired on 29th of March, so his payroll area was changed from biweekly to monthly on 29th. For retire we are running the p

  • Checks on vendors during the creation of PO with ME21N

    Hi all, i have this problem: during the creation of a Purchase Order, for some types of them i have to bypass some checks that are made by standard on the Vendor. Is it possibile to do? if it is, how can i do it? Thanks Lello

  • Converting a java string to a date.

    I am working on extending an EO and I have a situation where I must convert a string to a date before passing it to a method. The string is in the format "DD-MON-YYYY". I am using the following code and get an error "incompatible types: found: java.u

  • Photo Quality on ATV

    Hi Just synced my itunes photos with the ATV but the photos are not as clear as they are on my Mac. Also in ATV when you preview the pictures before going into the folders the images are fine (i presume as they are smaller) but when you go into the f

  • Sometimes my power supply gets hot

    I have the newest MacBook Pro 15 with the 2.5 Ghz Intel i7. I've noticed that sometimes my power transformer gets pretty when charging the laptop. Other times it doesn't get warm at all. Why would this happen? Is there something wrong with it?