SQL/MX Programming Manual for Java

SQL/MX Programming Considerations
HP NonStop SQL/MX Programming Manual for Java523726-003
4-11
SET TABLE TIMEOUT Statement
SET TABLE TIMEOUT Statement
The SET TABLE TIMEOUT statement sets a dynamic value for a lock timeout or a
stream timeout in the environment of the current session. A SET TABLE TIMEOUT
statement with a particular connection context affects only those statements that use
the same connection context class as SET TABLE TIMEOUT.
For the syntax of the SET TABLE TIMEOUT statement, see the SQL/MX Reference
Manual.
ANSI Compliance and Portability
If program portability is important, note that the SET TABLE TIMEOUT statement is an
SQL/MX extension to the ANSI standard.
Scope of the SET TABLE TIMEOUT Statement
The SET TABLE TIMEOUT statement is unusual because it affects both static and
dynamic SQL statements in an SQLJ program, but it follows dynamic scope rules (that
is, control flow scope) for all SQL statements, including static statements.
Placement of the SET TABLE TIMEOUT Statement
Place a SET TABLE TIMEOUT statement anywhere an executable statement is
allowed in an SQLJ program. You cannot place this statement at the top-level scope of
a program where you code class declarations. If you associate a connection context
with a SET TABLE TIMEOUT statement, place the SET TABLE TIMEOUT statement
after the instantiation of the connection context object.
Example
In this example, the SET TABLE TIMEOUT statement sets the lock timeout for the
SELECT statement to 1 minute while all other tables use a lock timeout of 30 seconds:
/* Set lock timeout for all tables to 30 seconds */
#sql [ctx] {SET TABLE * TIMEOUT '3000'};
/* Set lock timeout for the customer table to 1 minute */
#sql [ctx] {SET TABLE customer TIMEOUT '6000'};
#sql [ctx] {SELECT custnum, custname, street,
city, state, postcode
INTO :hv_custnum, :hv_custname; :hv_street,
:hv_city, :hv_state, :hv_postcode
FROM customer
WHERE custnum = :hv_custnum};
/* Reset the timeout value for the customer table
* to 30 seconds, which was set for all tables */
#sql [ctx] {SET TABLE customer TIMEOUT RESET};