Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
pkelly
Specialist
Specialist

Help on Exists

I have loaded a table from my live system which has a field called tmpRun which holds a run number.

I am then trying to bring in another table via SQL but only bring ion records where "veh-run" value = tmpRun value

The code I have is as follows...

TempPickOrder:

LOAD

"Ord-Type" AS OrderType,

"Ord-Num" AS OrderNumber,

"pick-num" AS PickNumber,

"veh-run" AS VehicleRun,

ourrecid AS OrigRecID;

SELECT

PUB."pck_ord"."Ord-Type",

PUB."pck_ord"."Ord-Num",

PUB."pck_ord"."pick-num",

PUB."pck_ord"."veh-run",

PUB."pck_item".ourrecid

FROM

PUB."pck_ord", PUB."pck_item"

WHERE

EXISTS("veh-run", tmpRun)

AND (PUB."pck_item"."Ord-Num" = PUB."pck_ord"."Ord-Num"

AND PUB."pck_item"."Ord-Type" = PUB."pck_ord"."Ord-Type"

AND PUB."pck_item"."pick-num" = PUB."pck_ord"."pick-num");

Keep getting a syntax error - any ideas where I am going wrong?

1 Solution

Accepted Solutions
danielrozental
Master II
Master II

Paul, when you're doing a SELECT the WHERE clause is a SQL clause run through the ODBC, you can't use qlikview functions.

You can use the exists like this

LOAD

"Ord-Type" AS OrderType,

"Ord-Num" AS OrderNumber,

"pick-num" AS PickNumber,

"veh-run" AS VehicleRun,

ourrecid AS OrigRecID

WHERE EXISTS("veh-run", tmpRun);

SELECT

PUB."pck_ord"."Ord-Type",

PUB."pck_ord"."Ord-Num",

PUB."pck_ord"."pick-num",

PUB."pck_ord"."veh-run",

PUB."pck_item".ourrecid

FROM

PUB."pck_ord", PUB."pck_item"

WHERE

(PUB."pck_item"."Ord-Num" = PUB."pck_ord"."Ord-Num"

AND PUB."pck_item"."Ord-Type" = PUB."pck_ord"."Ord-Type"

AND PUB."pck_item"."pick-num" = PUB."pck_ord"."pick-num");

But it will still cause all records to be extracted from the database not just the ones that were loaded previously.



View solution in original post

1 Reply
danielrozental
Master II
Master II

Paul, when you're doing a SELECT the WHERE clause is a SQL clause run through the ODBC, you can't use qlikview functions.

You can use the exists like this

LOAD

"Ord-Type" AS OrderType,

"Ord-Num" AS OrderNumber,

"pick-num" AS PickNumber,

"veh-run" AS VehicleRun,

ourrecid AS OrigRecID

WHERE EXISTS("veh-run", tmpRun);

SELECT

PUB."pck_ord"."Ord-Type",

PUB."pck_ord"."Ord-Num",

PUB."pck_ord"."pick-num",

PUB."pck_ord"."veh-run",

PUB."pck_item".ourrecid

FROM

PUB."pck_ord", PUB."pck_item"

WHERE

(PUB."pck_item"."Ord-Num" = PUB."pck_ord"."Ord-Num"

AND PUB."pck_item"."Ord-Type" = PUB."pck_ord"."Ord-Type"

AND PUB."pck_item"."pick-num" = PUB."pck_ord"."pick-num");

But it will still cause all records to be extracted from the database not just the ones that were loaded previously.