best way to perform this query from a performance perspective

  • Dears,

    I am having difficulty to write a query to do the below.  Can you please help me?

    Problem statement:

    I have several tables using the same methodology.  They store several inactive records and one active record. This is done in one layer called Raw.

    Sample of the table structure is:

    Columns : Attribute 1; Attribute 2; Attribute 3; attribute 4;  OpFlag

    Data Samp: 1; My name; My Adress; Age; High; I

    Data Samp: 2; My name2; My Adress2; Age2; High; U

    In this case, the active records is the one where opFlag is set as U

    As I mentioned, I have several tables like those (around 60 tables) which have this structure and have the OpFlag.

    Then, on the other layer (one layer above), called harmonized layer, we have the same tables , but those have only the active records of the previous layer.

    So, for each table in the raw zone, we have a correspondent table in the harmonized zone, which has the same structure but it does not have the opFlag, and it only contains the active record of each table. So it suffers an update, everytime there is a new active record.

    Now, we would like to create a logging table on the harmonized layer, like this:

    Colum names: TableName; Key; FieldName; OldValue; NEwValue; TimeStamp

    Sample data  : TableofHarmonized; Field1; MyName; Myname2; 07.09.2022 06:00:00

    Sample data  : TableofHarmonized; Field2; Address; MyAddress2; 07.09.2022 06:00:00

    In other words, for each new active record that we update in the harmonized layer, we would like to populate this table as well with the attributes that have changed.

    Can you please help me finding an algorithm for this?

    Thank you very much,

    Pedro

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    , which can be represented as :

    Attribute 1

     

     

     

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply