Sometimes, it is requested how to make a SQL query to a certain cell of a table and use that value as a tag or node. This is a possible way to do this in atvise scada:


1. Configure the ODBC connection to the database in your operating system. For MySQL for example:


2. Import the ODBC example function from atvise live:

3. Modify the script:

   3.1 Set your ODBC connection details

    3.2 Set your SQL Query

    3.3. Set the node you would like to represent the value coming from the SQL query (the node must be created previously)

    3.4. Assign the query result to the node value


Example:


4. Test it:

    4.1 Check the original value on the database using some SQL client (in this case, Workbench for MySQL):

    


    4.2 Run the script and watch how the QueryTag node value has been updated with the SQL query result:



5. Now move the script to Script Library if you would like to call this script from a server event (tag change, alarm, timer, etc.), or move it to webMI Methods Scripts if you would like to call this script form a client event (operator press a button in the screen, etc.).