Database - SVDBConnection Functions​

Using SVDBConnection Functions​

How to query a database using the “Global Database Connection” and the the “SVDBConnection” that is located within the “Systems Function Library”.

The following examples will help the user understand how the global database connection can be used with the “SVDBConnection” located within the “System Functions Library” to query the database.

A separate chapter will describe different ways to use the “SVDBConnection” to query the database without using the “Global Database Connection”. Using the “Database Connection” approach is a simpler more direct approach to database query.

NOTE: The highlighted functions above contain an input parameter called “connParameter” which is the name of the global database connection.

Using SVDBConnection.Select() function

  • The example below shows a script that will read values from a table in the database and write these values on a Datatype Tag reflects what can be done with the () function
  • The Data Type configured:

  • The Tag configured:

  • The table in the database:

  • The Script configured. The script will run a select query using the “Global Database Connection – PostgresSQL001” and all the records retrieved will be saved to the dynamic array tag. If an exception occurs, the result will be null and the script logs an error.

NOTE: The first parameter of SVDBConnection.Select is the global database name, In this example, “PostgresSQL001”.

Using SVDBConnection.Insert() function

  • The example below shows how to create a script that will insert a new table entry in the database.
  • Below shows the table in the database before the script is executed.

  • The script configured:

NOTE: The first parameter of SVDBConnection.Insert is the global database name, In this example, “PostgresSQL001”.

  • The table below shows records in the database after the script is executed:

Using SVDBConnection.Update() function

  • The example below shows how to create a script that will alter values in a table in the database.
  • Below shows the table in the database before the script is executed:

  • The script configured:

NOTE: The first parameter of SVDBConnection.Update is the global database name, In this example, “PostgresSQL001”.

  • The table in the database after the script is executed:

Using SVDBConnection.Delete() function

  • The example below shows a script that will delete lines from the table in the database.
  • The table in the database before the script is executed:

  • The script configured:

NOTE: The first parameter of SVDBConnection.Delete is the global database name, In this example, “PostgresSQL001”.

  • The table in the database after the script is executed:

Scroll Up