DBQUERY Issue a SQL query |
Top Previous Next |
This script command is used to execute SQL statements on the currently open database the results of which may be processed using the DBGETRESULTS script command.
The built-in SQLite database engine will fail and return an $ERROR_DB_QUERY_FAILED error on queries that return more than 1000 rows. This row limit does not apply to ODBC connections made using a DSN. Any query returning columns with more than 4096 characters will fail with an $ERROR_DB_UNSUPPORTED_RESULT error.
Use of the FileLink SQL database commands assumes that you have a working knowledge of SQL databases and queries. It is beyond the scope of FileLink documentation or technical support to offer support or education related to SQL so the syntax and format of any command or query submitted via the DBQUERY script command is left to the script programmer.
The first query submitted to a newly created database (see DBUSE) should create any necessary table(s) that you wish to save data into. An example query to create a table named MyTable is shown below.
DBQUERY "create table MyTable (fld1 text primary key, fld2 text);"
Data may then be saved in the database as shown in the following example which adds two rows of data to the database.
DBQUERY "insert into MyTable values ( 'row1', 'data1' );" DBQUERY "insert into MyTable values ( 'row2', 'data2' );"
To locate data in the database, a query like the following might be used.
DBQUERY "select * from MyTable where fld1='row1';" IFERROR $ERROR_DB_QUERY_FAILED GOTO done
A whole depth and breadth of SQL commands may be submitted in this manner. Consult SQL documentation for possible queries and syntax. A good resource is http://www.sqlite.org. SQLite is the SQL database engine employed by FileLink.
Related Command(s): DBCLOSE, DBGETRESULTS, DBUSE
|