Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
sridhar_sigired
Creator
Creator

Incremental load issue

Hi,

Note: I am providing the example of my issue. Experts, please help me on this problem.

I have a Tables SALES, SALES_DELETED in SQL Server.

SALES_TABLE

    

IDSALES_AMNTINSERTED TIMEUPDATED TIME
1100012/23/15 1:0012/23/15 1:00
2150012/23/15 1:0012/23/15 1:00
3200012/23/15 1:0012/23/15 1:00
4500012/23/15 2:0012/23/15 2:00
550012/23/15 2:0012/23/15 2:00
6100012/23/15 2:0012/23/15 2:00
7150012/23/15 2:0012/23/15 2:00
8200012/23/15 3:0012/23/15 3:00
9500012/23/15 3:0012/23/15 3:00
1050012/23/15 3:0012/23/15 3:00

SALES_DELETED:

   

IDDELETED TIMEFLAG
1112/23/15 1:00Y
1212/23/15 1:00Y
1312/23/15 1:00Y
1412/23/15 2:00Y
1512/23/15 2:00Y

In database, triggers are available on SALES_TABLE.

Trigger 1: Inserted&Updated - Displays default SYSDATE for inserted and updated records (For newly inserted records, INSERTED TIME and UPDATED TIME is same, whereas UPDATED TIME vary for updated records)

Trigger 2: Deleted - Deleted records physically deletes from SALES_TABLE and Added in SALE_DELETED Table.

Here i have to perform INCREMENTAL LOAD for SALE_TABLE. Please find the attached script.

Triggers are running every one hour. My Incremental load script is working fine when i reload QVW after triggers are performed on SQL Server.

Whereas if i reload my QVW simultaneously when triggers are running, then i am not receiving the deleted records into deleted QVD and they are not removing from mail QVD.

When i reload next time, i will be getting deleted records from max time of last road to current time. I am missing some of deleted records before max time of last road.

Now my main QVD contains some of deleted records as well.

My present solution is to reload the QVW after triggers performed on SQL.

However i will get this issue in long run.

Can anyone suggest permanent solution for this problem. It will be very helpful to me.

Thanks alot for your time.

Regards,

Sridhar

5 Replies
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Sridhar,

a couple of suggestions:

1 - when pulling the last execution datetime, maybe you should also pull the max DELETED TIME from DELETED QVD. This can then be used for the incremental extract from the SALES_DELETED table.

2 - I think your merge of DELETED QVD and SALES QVD is wrong. You may have the same record in both. The one coming from SALES QVD will have a FLAG of N, whereas the one from DELETED QVD will have a RecordDeleteStatus of Y.

Instead you should use a MAPPING load from DELETED QVD or your SALES_DELETED table.

When you load SALES QVD, use ApplyMap('MappingTable', ID, 'N'). If this is N, then it's not a deleted record.

Hope this helps.

Marcus

sridhar_sigired
Creator
Creator
Author

Hi Marcus,

Thanks for your suggestion.

About point 1:

When pulling the last execution datetime, maybe you should also pull the max DELETED TIME from DELETED QVD.

(If deleted records are ZERO then it will create a problem... means in the existing deleted QVD had zero records then there is no time time information in this QVD)

Any solution for this?

About point 2:

I incorrectly mentioned in the script about FLAG.

The one coming from SALES QVD will have a FLAG of N, and the one from DELETED QVD will have a FLAG of Y only. So finally i am filtering with where condition.

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Sridhar,

the solution for point 1 is maybe if you check if not isnull(qvdcreatetime('DELETED QVD'))

then retrieve the last DELETED TIME, otherwise manually set it, maybe with makedate(1900,1,1)

Regarding point 2, you are correct. The fact that you are first loading from DELETED QVD, then concatenating from SALES QVD where not Exists(ID) should deal with this correctly.

Another point though. You seem to have correctly dealt with incrementing your SALES QVD but not your DELETED QVD. You really should do this as if you don't then records which have been deleted in one load will not appear in the next load. This means that they still exist in SALES QVD, and so will reappear in your final table.

Marcus

sridhar_sigired
Creator
Creator
Author

Thank you Marcus.

For only deleted records, i do filter based on makedate (which filters every time all records with all deleted QVD, however it may take more time for reloading or i go for today()-1 like that based on reload time).

I hope it will work out even if the Triggers on database run on same time. However i will try to avoid that time to reload my QVW.

Thank you for your valuable suggestion and time to analyze my issue.

Regards,

Sridhar

sridhar_sigired
Creator
Creator
Author

Hi Marcus or All,

When i do incremental load first time, i will not have deleted delta QVD to pull the max date from last reload.

My requirement is to pull the max date from deleted delta QVD if available otherwise i need to pull default date of yesterday.

Does below one works? or any other best way to do? I am using ALT function here.

LOAD_MAXSALEDELETED_DATE:

        LOAD

            MAX(DELETED TIME) AS MAX_DATADELETED_DATE

        FROM [..\Data\SALES_DELETED.QVD](qvd);

// Converting data into required format

        LET v_LastReloadDateTime_DELETED=  Alt(Timestamp((PEEK('MAX_DATADELETED_DATE', 0, 'LOAD_MAXSALEDELETED_DATE')),'YYYY-MM-DD hh:mm:ss.fff'), Timestamp(Today()-1);

        DROP TABLE LOAD_MAXSALEDELETED_DATE;