Hi-
I am doing a query in a process flow activity, and I need to use a couple of labels on the token as criteria in the query. I tried a few methods, and they all either returned 0 or gave SQL errors.
First I tried using "puller. " as one might do in a "Pull from list" activity:
query("SELECT SKU, CurrentDemand FROM Status_SKUs WHERE CurrentDemand > 0 AND PICK_MODULE = puller.labelStorageLocation AND BAY = puller.labelCurrentBay ORDER BY BAY ASC LIMIT 1" );
This gave a SQL error e.g. "time: 4.712563 exception: Invalid SqlQuery object". I replaced puller.labelxx with getlabel(puller.xx and also with getlabel(token.xx and got the same result.
Then I tried using $1, $2 etc. to make the label references:
query("SELECT SKU, CurrentDemand FROM Status_SKUs WHERE CurrentDemand > 0 AND PICK_MODULE = $2 AND BAY = $1 ORDER BY BAY ASC LIMIT 1" ,getlabel(token,"labelCurrentBay"), getlabel(token,"labelStorageLocation"));
This didn't give SQL errors but it just returned 0.
Additional background that might help you understand what I need:
I was actually able to get what I wanted using a findmax() command. But it is very very slow (code profiler shows that activity taking 20 times more time than the next slowest activity) and my hope is that query() will be faster.
Here's the findmax that did what I wanted:
iSKUtoPick = findmax(gettablenum("Inputs_SKUs_UniqueSKUs",1,1), // Search all SKUS gettablenum("Status_SKUs", count, CURRENT_DEMAND) // For maximum current demand * (iAisle == gettablenum("Status_SKUs", count, PICK_MODULE)) // But only in current aisle * (iCurrentBay == gettablenum("Status_SKUs", count, BAY)), // And bay count, //Return the SKU # (since currently it equals the row #) (gettablenum("Status_SKUs", count, CURRENT_DEMAND) >0) ); // But return 0 if there is no demand
Thanks-
Craig