Pull from list on query

Pull from list on query

ddtsk
Contributor Contributor
36 Views
9 Replies
Message 1 of 10

Pull from list on query

ddtsk
Contributor
Contributor

[ FlexSim 24.1.1 ]


Hi Community ,

I have a use case where I am trying quire a custom pull of items from a global list where I have 3 conditions to check if it fails don't pull anything. I am getting error and I am unable to find where my code is going wrong.

Error :

time: 4.000833 exception: FlexScript exception: Could not parse query Select from PartList_feeder WHERE str == st ORDER BY Age Desc at MODEL:/Tools/ProcessFlow/VPI flow/Pull from List>variables/query

time: 4.000833 exception: Exception caught in start() of activity "Pull from List" in process flow "VPI flow". Continuing throw...

time: 4.000833 exception: Exception caught in Executive::processeventinlist().


Below is the snip of my case
1722261228783.png

Any feedback on what SQL Query should I use.

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

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

You are comparing a field called str with another called st - not the local variables if that's what you inteneded.


To compare the field str with the local variable st you can concatenate the string surrounded by single quotes or pass the st value in as a parameter.

Also note that comparisons in FlexQL can be done with a single =.

0 Likes
Message 3 of 10

ddtsk
Contributor
Contributor

Hi @Jason
Thanks for the Prompt Reply,
I tried changing the string into single quote and now I am getting a new error

Error

time: 4.000833 exception: Exception caught in start() of activity "Pull from List" in process flow "VPI flow". Continuing throw...

time: 4.000833 exception: Exception caught in Executive::processeventinlist().

Any feedback on what SQL Query should I use.

0 Likes
Message 4 of 10

jason_lightfootVL7B4
Autodesk
Autodesk
"SELECT * FROM PartList_feeder WHERE str='"+st+"' ORDER BY Age DESC"
0 Likes
Message 5 of 10

logan_gold
Community Manager
Community Manager

Hi @Hemanth Sai Kumar, was Jason Lightfoot's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes
Message 6 of 10

ddtsk
Contributor
Contributor

Hi Logan,
Thank you for the follow up on the above error, I tried writing the below syntax by @Jason Lightfoot I am still getting the same error.

1722574658949.png

1722572949203.png

0 Likes
Message 7 of 10

joerg_vogel_HsH
Mentor
Mentor

@Hemanth Sai Kumar Jason has demonstrated how to compose a string. Please assign this string into a string variable. You insert this string variable into your query. If you add this string directly into your query method, then the string ends by second occuring double quotation mark and a plus sign and a second string is not a correct parameter setting for a query method. You can parse only ONE string into this method.

0 Likes
Message 8 of 10

ddtsk
Contributor
Contributor

Hi,
I tried creating a local string ptt and I used that in query instead of calling str, I hope my syntax is correct now, I am still unable to return 1st str that satisfies both the conditions. 1722578171319.png

0 Likes
Message 9 of 10

joerg_vogel_HsH
Mentor
Mentor
string querystr = "SELECT • FROM PartList_feeder.part WHERE str="+st+" ORDER BY Age DESC" 

retum Table.query (querystr);

@Hemanth Sai Kumar, you are allowed to parse one string consisting of one opening and one closing double quotation mark into a query method.

0 Likes
Message 10 of 10

jason_lightfootVL7B4
Autodesk
Autodesk

But within the statement we are comparing a string literal which needs to be within its own quotes or apostrophes, otherwise the SQL interpreter considers it a fieldname.

0 Likes