DB2 10.5 for Linux, UNIX, and Windows

SET SCHEMA statement

The SET SCHEMA statement changes the value of the CURRENT SCHEMA special register.

This statement is not under transaction control. If the package is bound with the DYNAMICRULES BIND option, this statement does not affect the qualifier used for unqualified database object references.

Invocation

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

Authorization

None required.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-CURRENT-.          .-=-.                        
>>-SET--+---------+--SCHEMA--+---+--+-schema-name-----+--------><
                                    +-USER------------+   
                                    +-SESSION_USER----+   
                                    +-SYSTEM_USER-----+   
                                    +-CURRENT_USER----+   
                                    +-host-variable---+   
                                    '-string-constant-'   

Description

schema-name
This one-part name identifies a schema that exists at the application server. The length must not exceed 128 bytes (SQLSTATE 42815). No validation that the schema exists is made at the time that the schema is set. If a schema-name is misspelled, the error will not be caught, and that could affect the way that subsequent SQL statements execute.
USER
The value in the USER special register.
SESSION_USER
The value in the SESSION_USER special register.
SYSTEM_USER
The value in the SYSTEM_USER special register.
CURRENT_USER
The value in the CURRENT_USER special register.
host-variable
A variable of type CHAR or VARCHAR. The length of the contents of the host-variable must not exceed 128 bytes (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-aligned. 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 128 bytes.

Rules

Notes

Examples