Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

baarathi
Contributor II

Increamental Load ODBC connected (sql data)

LastUpdatedDate:

           Load

               max(Date("TDate")) as MaxDate;


Let varLastExec = Date(Peek('MaxDate', 0, 'LastUpdatedDate'));

Let varThisExec = Date(Now());


M:

LOAD

    TDate,

    "ANO",

    BILL,

    PAY,

    "SDATE",

    "DNO",

     ADJ,

    COM,

    Cheq,

    "mk",

    "user",

    tkey,

    place,

    "icode",

    pkey;

Concatenate

     Load TDate,

    "ANO",

    BILL,

    PAY,

    "SDATE",

    "DNO",

     ADJ,

    COM,

    Cheq,

    "mk",

    "user",

    tkey,

    place,

    "icode",

    pkey from lib://QVDs/xyz.qvd

     where not Exists(thekey);

inner join

load tkey;

sql select tkey from PAN.T;


if ('$(ScriptErrorCount)') = 0 then

Store M into [lib://QVDs/temp.qvd](qvd);

Let varLastExec = '$(varThisExec)';

endif

    


SQL SELECT

    "TDate",

    "ANO",

    BILL,

    PAY,

    "SDATE",

    "DNO",

     ADJ,

    COM,

    Cheq,

    "mk",

    "user",

    tkey,

    place,

    "icode",

    pkey

FROM PAN.T

where date(TDate) <= #'$varLastExec'#;


I was trying for increamental load, but there is an error occured while script is loaded, Is the above script correct to perform increamental load ?

19 Replies
surendraj
Valued Contributor

Re: Increamental Load ODBC connected (sql data)

Here tkey is correct one(key field) 

so it should be

where not Exists(tkey);

Employee
Employee

Re: Increamental Load ODBC connected (sql data)

Dear Baarathi,

The field thekey on the statement below:

where not Exists(thekey);


You should have loaded this field previously

Exists - script function ‒ Qlik Sense

Ricardo Gerhard
OEM Solution Architect
LATAM
baarathi
Contributor II

Re: Increamental Load ODBC connected (sql data)

the error persists even after that

beck_bakytbek
Valued Contributor III

Re: Increamental Load ODBC connected (sql data)

Hi Baarathi,

what do you expect to achieve by that? Do you want to insert, update or delete the values?

baarathi
Contributor II

Re: Increamental Load ODBC connected (sql data)

As far as now i want to achieve insert, update and delete. For update i have use where not exists(tkey) and for delete i have used inner join

baarathi
Contributor II

Re: Increamental Load ODBC connected (sql data)

Want to achieve all the three

beck_bakytbek
Valued Contributor III

Re: Increamental Load ODBC connected (sql data)

Baarathi

check this issue: Incremental load for beginner with example

i suppose, your order of tables is wrong

big_dreams
Contributor III

Re: Increamental Load ODBC connected (sql data)

I hope you read your error...

Error suggest

"Unexpected Token : thekey"


I don't see field with name as thekey in your table

Just replace with tkey instead of thekey


Regards,

surendraj
Valued Contributor

Re: Increamental Load ODBC connected (sql data)

Did you got the same error or another one?

the error is because of the field which doesn't exist in Database(thekey)

Please make sure to place correct key field in where not Exists(tkey).

As my observation Tkey was available in database.


Community Browser