dbpExecSQL

Purpose:

Execute advanced Structured Query Language (SQL) commands. You should be able to execute many types of SQL commands using this action. However, keep in mind that there are often differences in features and syntax between different databases. It's a good idea to refer to your database documentation to insure that the SQL commands you are planning to use are fully supported.

Category:

AdvancedSQL

Syntax:

dbpExecSQL "database id" "SQL" "results table"

database id

The name assigned to the database where the SQL commands will be executed.

SQL

The SQL commands to execute. As required by SQL conventions, multiple commands must separated with semicolons (;).

results table (optional)

This parameter can be used to enter the name of the table where you want the results of the query to be displayed. This may be the name of an existing database table or it can be a temporary table. If the table specified does not exist in the database, it is assumed to be a temporary table. Leave this parameter blank to auto detect the table name or if the query does not return any results.


A temporary table exists only while your publication is running and is not physically part of the database. However, most temporary tables derive their contents from real data, so any edits you make may affect other tables. A temporary table created with dpbExecSQL can be opened with the dbpOpenTable and displayed with dbpShowGrid actions. Actions that require a physical table, such as dbpAddField or dbpQuery, cannot be used with a temporary table.

Example:

dbpExecSQL "DB1" "RENAME TABLE Sales TO Orders" ""


The following example performs a simple query and sends the results to a temporary table, which is then opened and displayed in a grid:


dbpExecSQL "AddrBook" "SELECT * FROM Contacts WHERE State = 'NY'" "Temp1"

dbpOpenTable "AddrBook" "Temp1" ""

dbpShowGrid "AddrBook" "Temp1" "Rectangle1"

SQL Equivalent:


N/A