2014-09-25 46 views

回答

0

您需要日期(時間)列來標識新記錄。

然後,你可以這樣來做:

///$tab Main 
SET ThousandSep='.'; 
SET DecimalSep=','; 
SET MoneyThousandSep='.'; 
SET MoneyDecimalSep=','; 
SET MoneyFormat='#.##0,00 €;-#.##0,00 €'; 
SET TimeFormat='hh:mm:ss'; 
SET DateFormat='DD.MM.YYYY'; 
SET TimestampFormat='DD.MM.YYYY hh:mm:ss[.fff]'; 
SET MonthNames='Jan;Feb;Mrz;Apr;Mai;Jun;Jul;Aug;Sep;Okt;Nov;Dez'; 
SET DayNames='Mo;Di;Mi;Do;Fr;Sa;So'; 

set vSourceDir = 'C:\devel\qlikview\2013\Incremental_Load\'; 

///$tab Initial 
// Initial data load 

/* 

Sales: 
LOAD OrderId, 
    ProductId, 
    CustomerId, 
    Amount, 
    date(Date_updated) as Date_updated 
FROM 
$(vSourceDir)Data.xlsx 
(ooxml, embedded labels, table is Orders); 

STORE Sales INTO $(vSourceDir)sales.qvd (qvd); 

*/ 
///$tab Load from QVD 
// load sales.qvd 

Sales: 
LOAD OrderId, 
    ProductId, 
    CustomerId, 
    Amount, 
    date(Date_updated) as Date_updated 
FROM 
$(vSourceDir)sales.qvd 
(qvd); 

Sort_Sales: 
LOAD * 
Resident Sales 
Order By Date_updated; 

LET vLastUpdateDate = date(Peek('Date_updated', -1, 'Sort_Sales')); 


DROP TABLE Sales; 

///$tab Perform Incremental load 
// load only new (incremental) data 

Incremental: 
NoConcatenate 
LOAD OrderId, 
    ProductId, 
    CustomerId, 
    Amount, 
    date(Date_updated) as Date_updated 
FROM 
$(vSourceDir)Data.xlsx 
(ooxml, embedded labels, table is NewOrders) 
where date(Date_updated) >= '$(vLastUpdateDate)'; 



///$tab Update QVD 
// load data from qvd without the records that where changed 

Concatenate 
LOAD OrderId, 
    ProductId, 
    CustomerId, 
    Amount, 
    date(Date_updated) as Date_updated 
FROM 
$(vSourceDir)sales.qvd (qvd) 
where not exists(OrderId); 

STORE Incremental INTO $(vSourceDir)sales.qvd; 

這裏的解釋是https://www.youtube.com/watch?v=UkKTmnKSNQo

HTH

+0

它並不要求一定要日期/時間字段,只是一些是「保證」是單調遞增的。一些(很多?)數據庫使用整數作爲主鍵,所以只要您不關注滾動(或回填),這可能就足夠了。重要的是它是「可比的」,無論是連續還是整數。 – r2evans 2017-01-24 01:58:44

相關問題