SET
The SET statement allows you to set specific database dependent settings host variables.
Format 1
EXEC SQL [ AT Database ]
 
  SET Options 
 
END-EXEC
Format 2
EXEC SQL [ AT Database ]
 
  SET Host-Variable = Expression
 
END-EXEC
Syntax rules
1. No syntax check is performed on the content of Options.
2. Host-Variable is a host variable.
3. Expression specifies a value and can take a number of different forms. It can be a constant value, a special register, an arithmetic calculation, a function, etcetera...
General rules
1. Database identifies the active connection that will execute the query and must be previously defined using a Format 4 DECLARE statement.
Format 1
2. The SET statement is passed as is to the underlying JDBC driver. If the driver doesn’t understand it, an SQL error will be generated.
Format 2
3. A Format 2 SET statement is automatically transformed to a SELECT query to retrieve the result of the function. The resulting query depends on the compatibility activated through compiler options.
When using the -csdb2 option, the query is:
select Expression into :Host-Variable from sysibm.sysdumm1
When using the -csora option, the query is:
select Expression into :Host-Variable from dual
If none of the above options is used, the query is:
select Expression into :Host-Variable
 
Examples
Set the current transaction as READ ONLY and give it a name. This syntax is supported by the Oracle database
   exec sql
     set transaction read only name 'mytran'
   end-exec
Retrieve the current schema through the appropriate special register. This syntax is supported by the DB2 database and requires the -csdb2 compiler option
   exec sql
     set :wrk-schema = current schema
   end-exec