base.SqlHandle.execute

Executes a simple SQL statement (without result set).

Syntax

execute()

Usage

Call the execute() method to perform the SQL statement prepared by a prepare() call.

The execute() method is typically used for SQL statements that do not produce a result set, such as INSERT, UPDATE, DELETE or DDL statements like CREATE TABLE.

The execute() method can also be used to fetch a single row from a SELECT statement: After executing a SELECT statement, get the column values with getResultValue(). However, it is better practice to use open() + fetch() for SQL statements returning a result set.

If the SQL statement contains ? parameter place holders, issue a setParameter() call for each parameter, before executing the SQL statement.

As with standard Genero SQL instructions, SQL errors can be trapped with WHENEVER ERROR or TRY / CATCH blocks and by testing sqlca.sqlcode.

Example

DEFINE sh base.SqlHandle
...
CALL sh.execute()

For a complete example, see Example 1: SqlHandle with simple SQL.