SET host_variable

Provides information about OpenESQL connections and databases.

Syntax:

>>--EXEC SQL--.------------.--->
                      +-AT db_name-+

 >--SET :host_variable = >
 >------.-CURRENT CONNECTION-.------------.----------.-->
        +-CURRENT DATABASE---.------------.----------+
        +-OPTION-------------+-DATE-------+-USA------+
                                          +-EUR------+
                                          +-JIS------+
                                          +-ODBC-----+
                                          +-EXTERNAL-+
                                          +-ISO------+
                                          +-DEFAULT--+
                             +-TIME-------+-USA------+
                                          +-EUR------+
                                          +-JIS------+
                                          +-ODBC-----+
                                          +-EXTERNAL-+
                                          +-ISO------+
                                          +-DEFAULT--+
                             +-DATEDELIM--+-char-----+ 
                             +-TIMEDELIM--+-char-----+
                             +-TSTAMPSEP--+-char-----+
                             +-DETECTDATE-+-CLIENT---+
                                          +-SERVER---+
                                          +-OFF------+
 >---END EXEC---><

Parameters:

AT db_name The name of a database that has been declared using DECLARE DATABASE. This clause is not required, and if omitted, the connection automatically switches to the connection associated with the DECLARE CURSOR statement if different than the current connection, but only for the duration of the statement.
host_variable A PIC X(n) host variable
char Any single printable character or space
Note: For a full description of each option and its corresponding parameters, see the equivalent SQL Compiler Directive Options topic as listed in the Related reference section below.

Comments:

This statement returns the name of the current connection or the type of database for the current connection as specified in the EXEC SQL CONNECT statement in the specified host variable.

If there is no current open connection, host_variable is set to NONE for both CURRENT CONNECTION and CURRENT DATABASE.

With CURRENT CONNECTION, you can use host_variable in a subsequent EXEC SQL SET CONNECTION statement.

With CURRENT DATABASE, if there is a current open connection, host_variable is set to one of the following values, depending on the connection:

  • DB2
  • SQLSERVER
  • ORACLE
  • POSTGRESQL
  • OTHER
In addition to the OPTION syntax specified above, you can optionally place an equals (=) sign between the option and its parameter. For example, the following are equivalent:
exec sql set :myhostvar option date EUR end-exec
and
exec sql set :myhostvar option date=EUR end-exec