Sets an execution option.
SET OPTION option_keyword = value
The SET OPTION
statement is used to set execution options, such as the compile mode, SQL configuration settings, and the locale settings governing date, time, and numeric conventions. Only one keyword option can be set by each SET OPTION
Other SET OPTION
arguments (not documented here) are parsed by InterSystems IRIS for SQL compatibility, but perform no operation.
Because SET OPTION
prepares and executes quickly, and is generally run only once, InterSystems IRIS does not create a cached query for SET OPTION
in ODBC, JDBC, or Dynamic SQL.
The following options are supported by InterSystems IRIS:
The COMPILEMODE option sets the compile mode to DEFERRED, IMMEDIATE, INSTALL, or NOCHECK for the current namespace. The default is IMMEDIATE. Changing from DEFERRED to IMMEDIATE compile mode causes any classes in the Deferred Compile Queue to be compiled immediately. If all class compilations are successful, InterSystems IRIS sets SQLCODE to 0. If there are any errors, SQLCODE is set to -400. Class compilation errors are logged in the ^mtemp2 ("Deferred Compile Mode","Error"). If SQLCODE is set to -400, you should view this global structure for more precise error messages. The INSTALL compile mode is similar to the DEFERRED compile mode, but it should only be used for DDL installations where there is no data in the tables.
The NOCHECK compile mode is similar to IMMEDIATE, except that it skips checking of the following constraints when compiling: If a table is dropped, InterSystems IRIS does not check foreign key constraints in other tables that reference the dropped table. If a foreign key constraint is added, InterSystems IRIS does not check existing data to ensure that it is valid for this foreign key. If a NOT NULL constraint is added, InterSystems IRIS does not check existing data for NULLs or assign the field’s default value. If a UNIQUE or Primary Key constraint is deleted, InterSystems IRIS does not check if a foreign key in this table or another table references the dropped key.
The LOCK_TIMEOUT numeric option lets you set the default lock timeout for the current process. The LOCK_TIMEOUT value
is the number of seconds to wait when trying to establish a lock during SQL execution. This lock timeout is used when a locking conflict prevents the current process from immediately locking a record, table, or other entity for a LOCK
, or SELECT
operation. InterSystems SQL continue to try to establish the lock until the timeout expires, at which point an SQLCODE -110 or -114 error is generated.
Available values are positive integers and zero. The timeout setting is per process. You can determine the lock timeout setting for the current process using the GetProcessLockTimeout()
If you do not set the lock timeout for the current process, it defaults to the current system-wide lock timeout setting. If your ODBC connection disconnects and reconnects, the reconnected process uses the current system-wide lock timeout setting. The default system-wide lock timeout is 10 seconds.
For further details on locking conflicts and per-process and system-wide SQL lock timeout settings, refer to the LOCK
The PKEY_IS_IDKEY boolean option specifies whether primary keys are also ID keys system-wide. Available values are TRUE and FALSE. If TRUE, the primary key is created as an ID key. (That is, the primary key of the table also becomes the IDKey index in the class definition.) This may improve performance, but has the limitation that a primary key thus created cannot be subsequently modified. Once set, you cannot change the value assigned to a primary key, nor can you assign a different key as the primary key. Use of this option also changes the primary key collation default; primary key string values default to EXACT collation. If FALSE, the primary key and ID key are defined as independent, primary key values are changeable, and primary key string values default to the current collation type default
, which is SQLUPPER by default.
To set the PKEY_IS_IDKEY option, you must have the %Admin_Manage:USE privilege. Otherwise, you receive an SQLCODE -99 error (Privilege Violation). Once set, this option takes effect system-wide for all processes. The system-wide default for this option can be set using:
The PKEY_IS_IDKEY setting remains in effect until reset through another SET OPTION
PKEY_IS_IDKEY or until the InterSystems IRIS Configuration is reactivated, which resets this parameter to the InterSystems IRIS System Configuration setting.
The SUPPORT_DELIMITED_IDENTIFIERS boolean option specifies whether delimited identifiers are supported system-wide. Available values are TRUE and FALSE. If TRUE, a string delimited by double quotation marks is considered an identifier within an SQL statement. If FALSE, a string delimited by double quotation marks is considered a string literal within an SQL statement.
To set the SUPPORT_DELIMITED_IDENTIFIERS option, you must have the %Admin_Manage:USE privilege. Otherwise, you receive an SQLCODE -99 error (Privilege Violation). Once set, this option takes effect system-wide for all processes. The SUPPORT_DELIMITED_IDENTIFIERS setting remains in effect until reset through another SET OPTION
SUPPORT_DELIMITED_IDENTIFIERS or until the InterSystems IRIS Configuration is reactivated, which will reset this parameter to the System Configuration setting in the Management Portal
The system-wide default for this option can be set as follows:
Locale options are keyword options used to set your InterSystems IRIS Locale settings for date, time, and numeric conventions for the current process. The available keyword options are AM, DATE_FORMAT, DATE_MAXIMUM, DATE_MINIMUM, DATE_SEPARATOR, DECIMAL_SEPARATOR, MIDNIGHT, MINUS_SIGN, MONTH_ABBR, MONTH_NAME, NOON, NUMERIC_GROUP_SEPARATOR, NUMERIC_GROUP_SIZE, PM, PLUS_SIGN, TIME_FORMAT, TIME_PRECISION, TIME_SEPARATOR, WEEKDAY_ABBR, WEEKDAY_NAME, and YEAR_OPTION. All of these options can be set to a literal, and all take a default (American English conventions). The TIME_PRECISION option is configurable (see below). If you set any of these options to an invalid value, InterSystems IRIS issues an SQLCODE -129 error (Illegal value for SET OPTION
locale property). See the ObjectScript $ZDATETIME
function for an explanation of date and time formats and options.
|Date/Time Option Keyword
||String. Default is 'AM'
||Integer. Default is 1. Available values are 0 through 15. For an explanation of these date formats, see the ObjectScript $ZDATE function.
||Integer. Default is 2980013 (12/31/9999). Can be set to an earlier date, but not to a later date.
||Positive Integer. Default is 0 (12/31/1840). Can be set to a later date, but not to an earlier date.
||Character. Default is '/'
||Character. Default is '.'
||String. Default is 'MIDNIGHT'
||Character. Default is '-'
||String. Default is ' Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'. (Note that this string begins with a space character, which is the default separator character.)
||String. Default is ' January February March April May June ... November December'. (Note that this string begins with a space character, which is the default separator character.)
||String. Default is 'NOON'
||Character. Default is ','
||Integer. Default is 3.
||String. Default is 'PM'
||Character. Default is '+'
||Integer. Default is 1. Available values are 1 through 4. For an explanation of these time formats, see the ObjectScript $ZTIME function.
||Integer from 0 through 9 (inclusive). Default is 0. The number of digits of fractional seconds. Configurable, as described below.
||Character. Default is ':'
||String. Default is ' Sun Mon Tue Wed Thu Fri Sat'. (Note that this string begins with a space character, which is the default separator character.)
||String. Default is ' Sunday Monday Tuesday Wednesday Thursday Friday Saturday'. (Note that this string begins with a space character, which is the default separator character.)
||Integer. Default is 0. Available values are 0 through 6. For an explanation of these ways of representing 2-digit and 4-digit years, see the ObjectScript $ZDATE function.
SQL date functions: DAYNAME