SQL query execution and monitoring

You can monitor and modify the execution of an SQL query by using the execution context associated with it. An execution context is an instance of the class sqlj.runtime.ExecutionContext; an execution context is associated with each executable SQL operation in an Embedded SQLJ program.

You can supply an execution context explicitly for an SQL statement:
#sql [execCtx] {SQL_statement};

If you do not explicitly supply an execution context, the SQL statement uses the default execution context for the connection context you are using.

If you want to supply an explicit connection context and an explicit execution context, the SQL statement looks like this:
#sql [connCtx, execCtx] {SQL_statement };

You use the getExecutionContext() method of the connection context to obtain that connection’s default execution context.

The execution-context object has attributes and methods that provide information about an SQL operation and the ability to modify its execution.

For each of the following attributes, there is a method called getattribute that reads the value of the attribute, and a method called setattribute that sets its value. The attributes are:
Attribute Description

MaxRows

The maximum number of rows a query can return

MaxFieldSize

The maximum number of bytes that can be returned as data for any column or output variable

QueryTimeout

The number of seconds to wait for an SQL operation to complete

SQLWarnings

Any warnings that occurred during the last SQL operation

UpdateCount

The number of rows updated, inserted, or deleted during the last SQL operation