Tuesday, January 24, 2017

Date time stamp handling with incremental load using Oracle DB.


  • Take Max date from existing QVD file.


maxDate:
load
max(date) as maxDate
FROM
..\1_QVD\your-qvd-file.qvd (qvd);

let vSERVICE_MONITORINGMaxDate = date(peek('maxDate',0,'maxDate'),'DD-MM-YY hh:mm:ss'); // max date parameter

Final_Table:
SQL SELECT *
FROM DB_Table
where to_date(to_char(REQUEST_TIMESTAMP,'DD-MM-RR HH24:MI:SS')) >to_date('$(vSERVICE_MONITORINGMaxDate)','DD-MM-RR HH24:MI:SS');
Concatenate
LOAD *
FROM
[..\1_QVD\your-qvd-file.qvd] (qvd);
store Final_Table into ..\\1_QVD\your-qvd-file..qvd;
drop table Final_Table;
drop table maxDate;


We can also check whether QVD file is empty or not with below Code.

File:
LOAD
QvdNoOfRecords('..\\1_QVD\our-qvd-file.qvd') AS FileNumberOfRecords
autogenerate 1;

let vFileNumberOfRecords = peek('FileNumberOfRecords');


//If file doesn't exist run a full load else run incremental
if '$(vFileNumberOfRecords)' = '' then

//full load
Final_Table:
SQL SELECT *
FROM DB_Table;
store Final_Table into ..\\1_QVD\your-qvd-file.qvd;
drop table Final_Table;
ENFIF


No comments:

Post a Comment