Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Xabinav
Creator
Creator

How to create incremental load using 2 fields ?

Hi

I trying to write script of an incremental load using 2 fields (VehicleID , RowID).

I would appreciate your help in writing the code for the process of incremental loading.

I want to take each time the new Data (Increment), which does not appear in the existing table, and add it to the existing data (Initial Data) and update if data was changed. 

Thanks. 

Initial Data: 

VehicleID RowID
12345 1
12345 2
12345 3
21212 1

 

Increment: 

VehicleID RowID
12345 4
21212 2
34343 1
Labels (1)
3 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Make a composite key field and use that field as your Where not Exists(Key) clause.

VehicleID & '|' & RowID as Key

-Rob

Xabinav
Creator
Creator
Author

Thanks Rob.

'Where not Exists' clause doesn't work well in this case because I read data from SQL  (SQL SELECT ... FROM)

I have tried to write it like this, It works but doesn't seem to shorten the reload time.

There is another way to write it ? 

Source:
LOAD  
     VehicleID&'|'&RowID as Key_Source,
     *
FROM
[..\QVDs\Source.qvd](qvd);

Concatenate(Source)
LOAD 
     VehicleID&'|'&RowID as Key,
     *
Where Not Exists (Key_Source, VehicleID&'|'&RowID);

DROP FIELD Key_Source

SQL SELECT *
FROM DB.dbo.SQL;
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The DROP FIELD should come after the SQL Select.

Concatenate(Source)
LOAD  *
Where Not Exists (Key_Source, VehicleID&'|'&RowID)
;
SQL SELECT *
FROM DB.dbo.SQL;

DROP FIELD Key_Source