I have used the following SQL Query Binding in many DropDown List Components (In Vision) to populate the DropDown List (Data) for user selection. The project I am currently working on is Ignition Version 8.1.48
Whatever table you are selecting from doesnât have a column called No Selection. If you are trying to just have âNo Selectionâ as text in the second column, wrap it in single quotes â â. Double quotes â â in SQL denote identifiers, such as table or column names.
This isnât currently affecting the project I am working on it is just an annoyance since it has worked for me so many times before. I did realize that I am now working with SQL Server and all me previous projects were in MySQL. Could that be the difference?
MySQL has more standard syntax, MSSQL has customised and made so much of its query language non-standard that itâs very time consuming switching a nice working Ignition project between the two. Postgres to MySQL is a couple of minutes normally.
This is true for the majority of stuff, but even Postgres uses double quotes for identifiers, so looks like MySQL is the odd one out here in this case.
There is a second kind of identifier: the delimited identifier or quoted identifier. It is formed by enclosing an arbitrary sequence of characters in double-quotes ("). A delimited identifier is always an identifier, never a key word.
This makes sense now. After changing the double quote âNo Selectionâ to single quotes, âNo Selectionâ I jumped to the conclusion that the error was still flagging the âNo Selectionâ part of the query. I tried Cast(batch as nvarchar) AS Label and received the same error msg, converting varchar to bigint. Here is another wrinkle in my first question. The SQL Query that is installed and currently functioning is the following â
Why does this one convert the bigint to varchar and as soon as I try to display some defaults like the UNION with the â%"â and âNo Selectionâ throw an error?
Iâm an old man and learning new things is still fun.
Technically in the simpler SQL, the SQL is NOT converting anything to nvarchar. The data is being provided back as BIGINT, and java(Ignition) uses it as such. There might be some java stringify happening to make the selected label value in the dropdown a string, but thatâs all on Ignition side.
Regarding the Union, I just realized you need to cast BOTH columns as NVARCHAR. % is not a valid integer value. So you would need: SELECT CAST(batch as nvarchar) as Value, CAST(batch as nvarchar) as Label
Iâm guessing MySQL would look at the union columns and determines which type worked for both columns, hence no explicit casting.
The SQL standard calls for double quotes around identifiers, and single quotes around values.
Out of the box, MSSQL and MySQL and MariaDB use other characters for identifier quotes, but can be configured to use double quotes. PostgreSQL and Oracle follow the standard.
I appreciate your help. I only have three customers that use ignition and sometimes I have long periods where I donât get to work with it. Iâm just old enough that I forget⌠everthing.