DBQUERY Issue a SQL query |
Top Previous Next |
This script command is used to issue a SQL query to the currently open database file.
Use of the Robo-FTP SQL database commands assumes that you have a working knowledge of SQL databases and queries. It is beyond the scope of Robo-FTP 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 Robo-FTP.
When a query is submitted, Robo-FTP saves up to 1000 rows of results which may be obtained via the DBGETRESULTS script command. Any query resulting in more than 1000 rows of results will fail with a $ERROR_DB_QUERY_FAILED error.
Related Command(s): DBCLOSE, DBGETRESULTS, DBUSE |