MvQUERY#
Runs an SQL query that does not return any results, such as an create, update, delete, or insert.
Syntax
<MvQUERY NAME = "string: { expression } | literal"
QUERY = "string: { expression } | literal"
FIELDS = "{ expression } | variable list">
If NAME
is omitted, the query applies to the primary database. This must be an xBase3 or MySQL data source.
SQL queries that return results are handled by first opening a view with <MvOPENVIEW>
. A view is a collection of database records retrieved by a particular SQL query.
Attributes#
Attribute | Description |
---|---|
NAME |
Optional Database alias. When a database is opened with MvOPEN , it is referenced in all other database commands by the alias. If omitted, the primary database is assumed. The database must be open. |
QUERY |
The query string used to access the records. For field variables used in the string, the question mark (e.g. ? ) can be used as a placeholder, for FIELDS . |
FIELDS |
Optional. A comma delimited list of field variables used in the QUERY string. For each ? found a field variable will be substituted in sequence. |
Example#
This query updates a record in the Products table in the Merchant database.
<MvOPEN NAME = "Merchant" DATABASE = "mydatabasefile@localhost" TYPE = "mysql"
USERNAME = "{ l.username }" PASSWORD = "{ l.password }">
<MvQUERY NAME = "Merchant"
QUERY = "{ 'UPDATE Products SET name = ? WHERE id = ?' }"
FIELDS = "l.name, l.product_id">