IBM Books

SQL Reference

SET SCHEMA

The SET SCHEMA statement changes the value of the CURRENT SCHEMA special register. It is not under transaction control. If the package is bound with DYNAMICRULES BIND option, this statement has no effect.

Invocation

The statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared.

Authorization

No authorization is required to execute this statement.

Syntax

        .-CURRENT-.          .-=-.
>>-SET--+---------+--SCHEMA--+---+----+-schema-name-----+------><
                                      +-USER------------+
                                      +-host-variable---+
                                      '-string-constant-'
 

Description

schema-name
This one-part name identifies a schema that exists at the application server. It must be a short SQL identifier (SQLSTATE 42815). No validation that the schema exists is made at the time that the schema is set. If a schema-name is misspelled, it will not be caught, and it could affect the way subsequent SQL operates.

USER
The value in the USER special register.

host-variable
A variable of type CHAR or VARCHAR. The length of the contents of the host-variable must not exceed 8 (SQLSTATE 42815). It cannot be set to null. If host-variable has an associated indicator variable, the value of that indicator variable must not indicate a null value (SQLSTATE 42815).

The characters of the host-variable must be left justified. When specifying the schema-name with a host-variable, all characters must be specified in the exact case intended as there is no conversion to uppercase characters.

string-constant
A character string constant with a maximum length of 8.

Rules

Notes

Examples

Example 1:  The following statement sets the CURRENT SCHEMA special register.

  SET SCHEMA RICK

Example 2:  The following example retrieves the current value of the CURRENT SCHEMA special register into the host variable called CURSCHEMA.

  EXEC SQL VALUES (CURRENT SCHEMA) INTO :CURSCHEMA;

The value would be RICK, set by the previous example.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]