Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Doubt with Concatenate and duplicates

Hi,

I'm building up kind of an Incremental Load solution for one of my tables which connects to a SQL server.

I first read my old data from a qvd int ReitekContactsTemp and then I load the new one from the DB table into ReitekContactsTemp_1  . My goal is to append data of ReitekContactsTemp_1 to ReitekContactsTemp excluding duplicates of ReitekContacts_CONTACTID running the script more than once a day.

I tried to implement 2 different scenarios which gave me an error and I'd like you to help me in order to understand why:

Scenario 1) SQL Error due to the NOT EXIST condition. Obiously it is wrong but I really did not know how to deal with WHERE NOT EXISTS(ReitekContacts_CONTACTID); which should apply to the concatenation and not to the SQL query.


ReitekContactsTemp:

LOAD * from $(qvdCCarePath)ReitekContacts.qvd (qvd);


CONCATENATE (ReitekContactsTemp)

ReitekContactsTemp_2:

select

....

FROM

contact.contacts c

where ACCEPTED in ('Y','N','X')

and to_char(GDAY,'YYYY-MM-DD')='$(Yesterday)'

WHERE NOT EXISTS(ReitekContacts_CONTACTID);

Scenario 2)Table not found. Automatically data from SQL query is appended to the ReitekContactsTemp table as they have the same fields names. In this case i cannot apply the condition WHERE NOT EXISTS(ReitekContacts_CONTACTID) to the concatenation.

Let Yesterday=date(Today()-1);

ReitekContactsTemp:

LOAD * from $(qvdCCarePath)ReitekContacts.qvd (qvd);

ReitekContactsTemp_1:

select

...

FROM

contact.contacts c

where ACCEPTED in ('Y','N','X')

and to_char(GDAY,'YYYY-MM-DD')='$(Yesterday)';

CONCATENATE (ReitekContactsTemp)

ReitekContactsTemp_2:

Load * Resident ReitekContactsTemp_1

WHERE NOT EXISTS(ReitekContacts_CONTACTID);

Temporary solution:

I Changed the script so it runs once a day and i am sure that it won't insert twice the same line.

Let Yesterday=date(Today()-1);

ReitekContactsTemp:

LOAD * from $(qvdCCarePath)ReitekContacts.qvd (qvd);

ReitekContactsTemp_1:

select

...

FROM

contact.contacts c

where ACCEPTED in ('Y','N','X')

and to_char(GDAY,'YYYY-MM-DD')='$(Yesterday)';

1 Reply
Gysbert_Wassenaar

The first thing to understand is that Qlikview sends a select ... statement to the dbms. Qlikview only fills in variables by dollar expanding them if you used any. Otherwise the sql statement is send as is to the dbms. Qlikview doesn't parse it at all. It sends the sql, the dbms executes it and sends the results to Qlikview and Qlikview loads the results in a table.

What happens in scenario 1 is that you're mixing the not exist functionality of qlikview with that of your dbms. The result is that the dbms complains about a not exist clause that doesn't make sense to it.

What happens in scenario 2 is that the table ReitekContactsTemp_1 is not created. Because the fields are the same as in ReitekContactsTemp the data gets loaded into that table. Because ReitekContactsTemp_1 isn't created you get the error Table Not Found. I doubt it would work if you specified noconcatenate for ReitekContactsTemp_1.

Something that would definitely help is if your source database had a timestamp (aka datetime) field that could be used for incremental loading. Your GDAY field seems to work for daily reloads, but a shorter reload timeframe you need a timestamp. Perhaps your database administrator can help you out by adding such a field.


talk is cheap, supply exceeds demand