SQL path

The SQL path is an ordered list of schema names. The database manager uses the path to resolve the schema name for unqualified distinct type names (both built-in types and distinct types), function names, and procedure names that appear in any context other than as the main object of an ALTER, CREATE, DROP, COMMENT, LABEL, GRANT or REVOKE statement.

For example, if the SQL path is SMITH, XGRAPHIC, QSYS, QSYS2 and an unqualified distinct type name MYTYPE was specified, database manager looks for MYTYPE first in schema SMITH, then XGRAPHIC, and then QSYS and QSYS2.

The SQL path used is depends on the SQL statement:

  • For static SQL statements (except for a CALL variable statement), the path used is the value of the SQLPATH parameter on the CRTSQLxxx command. The SQLPATH can also be set using the SET OPTION statement.

    Start of changeThe path stored in programs, modules, service programs, routines, and triggers, is composed entirely of the system-schema-names associated with the schema names in the path. If the system-schema-name of a schema is renamed, it may be necessary to recreate these objects if they use SQL statements that depend on the path.End of change

  • For dynamic SQL statements (and for a CALL variable statement), the path used is the value of the CURRENT PATH special register. For more information about the CURRENT PATH special register, see CURRENT PATH.

If the SQL path is not explicitly specified, the SQL path is the system path followed by the authorization ID of the statement.

For more information about the SQL path for dynamic SQL, see CURRENT PATH.