Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
amit_saini
Master III
Master III

Incremental Load based on Primary Key without Date field Help!!!

Hi Folks ,

Can someone help we with incremental script for below EDID4 table having  "SEGNUM" as Primary Key , we don't have any date field in this table.

EDID4:   // IDoc Data Records from 4.0 onwards

Load

*;

SQL Select MANDT COUNTER DOCNUM HLEVEL SEGNUM SEGNAM PSGNUM DTINT2 SDATA  from EDID4

;

STORE * FROM EDID4 INTO D:\qvprod\qvd\SAP\KTX_100\EDID4.QVD;

DROP TABLE EDID4;

Thanks in advance!

Regards,

AS

9 Replies
jubarrosor
Partner Ambassador
Partner Ambassador

Hi AS:

Try something like this where vL.Segnum contain the max value of field Segnum loaded in the previous execution:

EDID4:

LOAD

    *

FROM (qvd);   

Concatenate(EDID4)

Load

*;

SQL

Select MANDT, COUNTER, DOCNUM, HLEVEL, SEGNUM, SEGNAM, PSGNUM, DTINT2, SDATA  from EDID4

WHERE SEGNUM > $(vL.Segnum);

STORE * FROM EDID4 INTO D:\qvprod\qvd\SAP\KTX_100\EDID4.QVD;

DROP TABLE EDID4;

Best Regards,

Juan P. Barroso

amit_saini
Master III
Master III
Author

do i need to define:

vL.Segnum=max(SEGNUM) ???

Thanks,

AS

manoj217
Creator III
Creator III

Hi Amit,

No Max function will not work because it is a aggregation function.

If you are working with the primary key and it consists a string means use this below variable.

let max=peek('SEGNUM',-1,'EDID4');

Regards,

Manoj

manoj217
Creator III
Creator III

Also use lastvalue(SEGNUM) it will also get the last value of the particular field.

amit_saini
Master III
Master III
Author

ok thanks!

Regards,
AS

amit_saini
Master III
Master III
Author

Hi,

I'm not sure , why I'm getting below error:

/QTQVC/OPEN_STREAM failed after 00:00:00 Key = SQL_ERROR (ID:00 Type:E Number:001 ">2" is invalid here (due to grammar). contains an invalid character or it is a keyword. (It might be possible to escape it using "!"). Or a space is missing or there is one space too many.)

SQL Select MANDT COUNTER SEGNUM HLEVEL DOCNUM SEGNAM PSGNUM DTINT2 SDATA  from EDID4

Where SEGNUM >2

I'm trying something like below:

EDID4:

LOAD MANDT,

     COUNTER,

     SEGNUM,

     HLEVEL,

     DOCNUM,

     SEGNAM,

     PSGNUM,

     DTINT2,

     SDATA

FROM

(qvd);

Last_Updated_SEGNUM:

Load max(SEGNUM) as MaxSEGNUM

Resident EDID4;

Let vLastUpdatedSEGNUM =peek('MaxSEGNUM',0,'Last_Updated_SEGNUM');

NoConcatenate

Incremental:

Load

   *;

SQL Select MANDT COUNTER SEGNUM HLEVEL DOCNUM SEGNAM PSGNUM DTINT2 SDATA  from EDID4

Where SEGNUM >$(vLastUpdatedSEGNUM);


Concatenate (Incremental)

LOAD MANDT,

     COUNTER,

     SEGNUM,

     HLEVEL,

     DOCNUM,

     SEGNAM,

     PSGNUM,

     DTINT2,

     SDATA

Resident EDID4

Where not Exists (SEGNUM);

Inner Join (Incremental)

Load

   SEGNUM;

SQL Select MANDT COUNTER SEGNUM HLEVEL DOCNUM SEGNAM PSGNUM DTINT2 SDATA  from EDID4

;

STORE * FROM Incremental INTO D:\qvprod\qvd\SAP\KTX_100\Incremental.QVD;

DROP Tables Last_Updated_SEGNUM, EDID4;

Thanks,

AS

amit_saini
Master III
Master III
Author

and SEGNUM is Primary Key.

SEG.PNG

Thanks,

AS

amit_saini
Master III
Master III
Author

Guys any suggestion???

Regards,

AS

neelamsaroha157
Specialist II
Specialist II

May be you can try not exist function in the where condition.

Check this out -

Incremental load with Primary Key