Using a tag value in a SQL query?

Hi there. i have a UDT that contains an expression tag and a query tag. i want to use the value of the expression tag in the query itself.

This is my expression tag
split({PathtoTag},"/")[7,0]

This is my query

SELECT TOP 1 (operationNumber) as OpNum
FROM CT_Part_Info
WHERE workstation = {tagvalue}
ORDER BY id DESC

I want to use the value of the expression tag and have my workstation= to that. but it does not work or seems is not possible. any recommendations?

Tips:

  1. When posting code, select it and press the </> button to format it. It will preserve indentation and do some syntax highlighting for you.
  2. It looks like you're working on a Vision application. If you edit your question title and add in the Vision tag it may help attract the Vision experts.

Pretty sure this isn't possible to do. You can't reference tags from tag property bindings, you can only reference the specific props in the list. You'll just have to live with using named queries instead

You are missing your tag reference in the screenshot. You also have no space before WHERE and FROM which will cause the query to fail.

image

Otherwise, it should work if your tag path and data type is correct.

There are other means to achieve what you are looking for and for security reasons it is best practice to create Named Queries


https://docs.inductiveautomation.com/display/DOC81/Named+Queries