Query problems for Pulling

Query problems for Pulling

ana_pc2
Not applicable
44 Views
9 Replies
Message 1 of 10

Query problems for Pulling

ana_pc2
Not applicable

[ FlexSim 20.2.3 ]

Hello! How are you all?

I am trying to code a query but I think I am having some troubles with the format of the string since the label Name is a mix of numbers and letters (Example: 67HYK). And if I leave it with only numbers, the query works, so I am guessing thereis where my problema is.

The label Name is a concat of two other labels, for example: ítem.label1 = 67, and ítem.label2 = HYK, and then ítem.Name = 67HYK (ítem.label1 + ítem.label2)… just in case this could be the problem.


I am pulling from a list with label Name, and this is my idea of the code but I get an Invalid pull query error, so I guess the error could be on this line:


string bname1 = Model.find("P1").Name;
string bname2 = Model.find("P2").Name;
string bname3 = Model.find("P3").Name;

string queryStr = "WHERE Name !=" + bname1 + " AND Name !=" + bname2 + " AND Name !=" + bname3 + " ORDER BY age DESC";

...

pulled = list.pull(queryStr, 1, addToBackOrders ? 1 : 0, current, partitionId, (removeFromList ? 0 : LIST_DO_NOT_REMOVE) | LIST_RETURN_BACK_ORDER_IF_NOT_FULFILL);


Any ideas to fix it??? Thanks! 🙂

0 Likes
Accepted solutions (1)
45 Views
9 Replies
Replies (9)
Message 2 of 10

ana_pc2
Not applicable

The label Name is pushed to the list like this:


Variant value = param(1);
Variant puller = param(2);
treenode entry = param(3);
double pushTime = param(4);

string final = value.label1+value.label2;

return /**/final/**direct*/;

0 Likes
Message 3 of 10

ana_pc2
Not applicable

And the label Name on Model.find("P1") comes from the same idea: Model.find("P1").label1 + Model.find("P1").label2

0 Likes
Message 4 of 10

aida_c2
Not applicable

Hi @ana.pc2, can you attach the model or an example model? I'm not sure if the problem is in the queryStr or in the pull code.

0 Likes
Message 5 of 10

jeff_nordgren
Not applicable

Hi @ana.pc2,

It's hard to know how to help without looking at your model. To receive a more accurate solution, please post your model or a sample model that demonstrates your question.

Proprietary models can be posted as a private question visible only to FlexSim U.S. support staff. You can also contact your local FlexSim distributor for phone or email help.

0 Likes
Message 6 of 10

ana_pc2
Not applicable

33891-captura.png

So this query should be different for each processor… 46401 can only be in one (all same type goes to same location, not different:1_0a or 2_0a

0 Likes
Message 7 of 10

ana_pc2
Not applicable

the query in this case will be :

string bname = current.label1 + current.label2;

string queryStr = /** \nQuery: *//***tag:query*//**/"WHERE B_P_Name == " + bname + " ORDER BY age DESC"/**/;

0 Likes
Message 8 of 10

ana_pc2
Not applicable

33893-captura.png

So the code that I posted on the first post is not recognizing ítems' label on the query (?), because it is sending 46401 to different locations when it should be != to any processors (on the query at least is showing) with label already to be able to pull any item.

0 Likes
Message 9 of 10

ana_pc2
Not applicable
Accepted solution

Oh, I think I got it. In case someone need it, this is how I fixed it:

Basically I changed all labels to numbers and use Variant instead of string...

I still wonder why it doesn't work with a string (mix of letters and numbers).

Message 10 of 10

jeff_nordgren
Not applicable

@ana.pc2,

You don't want to use a string for a label that might be used as a lookup or in some other process/function. Stings are a LOT slower than number are so it's better to use a number anyway.


0 Likes