Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have 2 tables that share the same key :
Tables are Data_Current and Data_Histo, with a key named Data_ID
I want to load records from Data_Current Table
and add, in the same table, records from Data_Histo for which the key Data_ID has not been already loaded from Data_Current Table.
What is the best practice in that situation?
Thanks for your help
Pierre.
LOAD * from Table1.qvd;
LOAD * from Table2.qvd where not exists(Data_ID);
Assuming you are loading from qvd file. If this is not the case, you would need to load RESIDENT, but you would need to load Data_ID as something else. But NOT EXISTS should work fine in either case. Check out EXISTS() function documentation.
Is Data_ID a unique key?
[Data]:
LOAD
Data_ID
,other fields
RESIDENT [Data_Current]
;
CONCATENATE ([Data])
LOAD
Data_ID
,other fields
RESIDENT [Data_Histo]
WHERE NOT EXISTS(Data_ID)
;