Es sql queryvalue

From EventScripts Community Encyclopedia


Overview

Syntax: es_sql queryvalue <db-name> <variable> "<SQL-string>"

Note: Command parameters are described inside the < and > characters. Optional parameters are contained within [ and ] characters.

Variation of this command that doesn't expand variables: es_xsql queryvalue

Description

Same as es_sql query, but stores only the first row/column value into variable. Useful for COUNT()/SUM() queries.

Parameters


Examples

See the ServerMail example in ES v1.5 for a detailed example.

// open a SQLite database file, creates/opens es_mydb.sqldb
es_sql open mydb |myscript
es_xset myvar 0
es_sql queryvalue mydb myvar "SELECT * FROM mytable WHERE myname='Mattie';"
if (server_var(myvar) != 0) then es_xmsg Found a result!


Notes

  • Must call es_sql open on the database before trying queries.
  • This is a synchronous call.
  • SQLite has very good performance, but it will be dependent on just how large the table is.
  • For complicated queries or large tables, it's recommended that you wait to perform the query until a more acceptable time.
  • Requires EventScripts v1.5.


See also

blog comments powered by Disqus