Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Experts
How we can Implement Update only in Incremental load ?
Note : Ignore Insert records (Perform only Update )
Thanks
Madhu
Hi madhu,
This script gives you the table of your original data but with modification to changed records and without addition of new:
Key | Hours | Status |
---|---|---|
100 | 2 | Completed |
101 | 3 | Completed |
102 | 10 | Completed |
There's a lot of renaming and dropping going on here and it can possibly be simplified. Anyway here it is:
OldDataSet:
Load
*,
Hash128(Key & '|' & Hours & '|' & Status) as HashKey;
Load * Inline [
Key, Hours, Status
100, 2, Completed
101, 3, Completed
102, 4, Pending];
NoConcatenate
ModifiedData:
Load
*
Where Exists(Key) and Not Exists(HashKey);
Load
*,
Hash128(Key & '|' & Hours & '|' & Status) as HashKey;
Load * Inline [
Key, Hours, Status
100, 2, Completed
101, 3, Completed
102, 10, Completed
103, 5, Completed];
Drop Field HashKey;
ModifiedData1:
Load
Key as ModKey,
Hours,
Status
Resident ModifiedData;
drop Table ModifiedData;
RENAME Table ModifiedData1 to ModifiedData;
NoConcatenate
NewDataSet:
Load * Resident OldDataSet Where Not Exists(ModKey, Key);
DROP Table OldDataSet;
NoConcatenate
ModifiedData1:
Load
ModKey as Key,
Hours,
Status
Resident ModifiedData;
drop Table ModifiedData;
RENAME Table ModifiedData1 to ModifiedData;
Concatenate (NewDataSet)
LOAD * Resident ModifiedData;
DROP Table ModifiedData;
Thanks for reply
In our case we are not using Date field
Example :
OldDataSet:
Key,Hours,Status
100,2,Completed
101,3,Completed
102,4,Pending
NewDataSet:
100,2,Completed
101,3,Completed
102,10,Completed
103,5,Completed
Here I want to update(only) , which record is modified (102 record only)
I dont want to load new record .
Please help to write the script
Thanks
Madhu
Hi madhu,
This script will give you a table called ModifiedData
Key | Hours | Status |
---|---|---|
102 | 10 | Completed |
OldDataSet:
Load
*,
Hash128(Key & '|' & Hours & '|' & Status) as HashKey;
Load * Inline [
Key, Hours, Status
100, 2, Completed
101, 3, Completed
102, 4, Pending];
NoConcatenate
ModifiedData:
Load
*
Where Exists(Key) and Not Exists(HashKey);
Load
*,
Hash128(Key & '|' & Hours & '|' & Status) as HashKey;
Load * Inline [
Key, Hours, Status
100, 2, Completed
101, 3, Completed
102, 10, Completed
103, 5, Completed];
Drop Table OldDataSet;
Drop Field HashKey;
Thanks for Your Reply
Itz working Perfectly
Hi madhu,
This script gives you the table of your original data but with modification to changed records and without addition of new:
Key | Hours | Status |
---|---|---|
100 | 2 | Completed |
101 | 3 | Completed |
102 | 10 | Completed |
There's a lot of renaming and dropping going on here and it can possibly be simplified. Anyway here it is:
OldDataSet:
Load
*,
Hash128(Key & '|' & Hours & '|' & Status) as HashKey;
Load * Inline [
Key, Hours, Status
100, 2, Completed
101, 3, Completed
102, 4, Pending];
NoConcatenate
ModifiedData:
Load
*
Where Exists(Key) and Not Exists(HashKey);
Load
*,
Hash128(Key & '|' & Hours & '|' & Status) as HashKey;
Load * Inline [
Key, Hours, Status
100, 2, Completed
101, 3, Completed
102, 10, Completed
103, 5, Completed];
Drop Field HashKey;
ModifiedData1:
Load
Key as ModKey,
Hours,
Status
Resident ModifiedData;
drop Table ModifiedData;
RENAME Table ModifiedData1 to ModifiedData;
NoConcatenate
NewDataSet:
Load * Resident OldDataSet Where Not Exists(ModKey, Key);
DROP Table OldDataSet;
NoConcatenate
ModifiedData1:
Load
ModKey as Key,
Hours,
Status
Resident ModifiedData;
drop Table ModifiedData;
RENAME Table ModifiedData1 to ModifiedData;
Concatenate (NewDataSet)
LOAD * Resident ModifiedData;
DROP Table ModifiedData;
Thanks Andrew Walker ,
Script working fine
Please mark the correct answer.
Thank you Richard.