Home > Class Reference > %SYS namespace > %SYSTEM.SQL

%SYSTEM.SQL

abstract class %SYSTEM.SQL extends %SYSTEM.Help

The %SYSTEM.SQL class provides an interface for managing SQL configurations.

You can use it via the special $SYSTEM object:

Do $SYSTEM.SQL.CurrentSettings()

You can call help to get a list of all entry points:

Do $SYSTEM.SQL.Help()

Method Inventory

Methods

classmethod ABS(val As %Library.String = "") as %Library.Float [ Language = objectscript ]
ABS returns the absolute value, which is always zero or a positive number

$SYSTEM.SQL.ABS(numeric-expression)

numeric-expression
A number whose absolute value is to be returned
ABS returns the same data type as numeric-expression. If numeric-expression is not a number (for example, the string 'abc') ABS returns 0. ABS returns NULL when passed a NULL value.
classmethod ALPHAUP(stringexp As %Library.String = "") as %Library.String [ Language = objectscript ]
ALPHAUP returns the Alphaup collation of the passed in value.
$SYSTEM.SQL.ALPHAUP(stringexp)
stringexp Any string expression value.
ALPHAUP converts all alphabetic characters to upper case (i.e., the ALPHAUP format) and removes all punctuation except commas and question marks.
classmethod CEILING(val As %Library.String = "") as %Library.Float [ Language = objectscript ]
CEILING is a scalar numeric function that returns the smallest integer greater than or equal to a given numeric expression

$SYSTEM.SQL.CEILING(numeric-expression)

numeric-expression
A number whose ceiling is to be calculated
classmethod CONVERT(expr As %Library.String = "", convto As %Library.String = "", convfrom As %Library.String = "") as %Library.String [ Language = objectscript ]
CONVERT is a SQL function that converts a given expression to a specified data type.

$SYSTEM.SQL.CONVERT(expr,convto,convfrom)

expr
The expression to be converted
convto
The data type to which expr is to be converted. Currently, only "SQL_TIMESTAMP", "SQL_POSIXTIME", "SQL_TIME", "SQL_DATE", "SQL_VARCHAR", "SQL_INTEGER", and "SQL_DOUBLE" are supported
convfrom
The data type of expr. Currently, only "SQL_TIMESTAMP", "SQL_POSIXTIME", "SQL_TIME", "SQL_DATE", "SQL_VARCHAR", "SQL_INTEGER", and "SQL_DOUBLE" are supported
CONVERT is a SQL function that converts expression expr from type convfrom to the specified data type convto.
The convfrom value is expected to be a Logical value for SQL_DATE and SQL_TIME. When converting from SQL_DATE, SQL_POSIXTIME, or SQL_TIME to SQL_TIMESTAMP, the input value is expected to be a logical %Library.Date, %Library.PosixDate, or %Library.Time value. When converting from SQL_VARCHAR to SQL_TIME, the input value is expected to be an ODBC %Library.Time formatted value. When converting from SQL_VARCHAR to SQL_DATE, the input value is expected to be an ODBC %Library.Date formatted value. When converting from SQL_DATE, SQL_POSIXTIME, or SQL_TIME to SQL_VARCHAR, the returned value will contain the ODBC format of the %Library.Date, %Library.PosixTime, or %Library.Time value.
classmethod CheckPriv(Username As %String, Object As %String, Action As %String, Namespace As %String = "", Grant As %Integer = 0) as %String [ Language = objectscript ]
Check if user has SQL privilege for a particular action.

Parameters:
Username
Name of the user to check. Required.
Object
ObjectType,ObjectName of the table, view, or procedure to check the privilege of. ObjectTypes are 1 (table), 3 (view), 9 (procedure). For example, "1,Sample.Person" or "9,SQLUser.My_Procedure". Required.
Action
Comma delimited string of actions letters to check privileges for. Actions are one or more of the letters "a,s,i,u,d,r,e" (in any order) which stands for ALTER,SELECT,INSERT,UPDATE,DELETE,REFERENCES,EXECUTE. Privilege "e" is only allowed for Procedures. CheckPriv will only return 1 if the user has privileges on all Actions specified. Required.
Namespace
Namespace object resides in (optional) default is current namespace
Grant
1/0 flag - check grant privileges (optional) default is 0

Returns:

  • 1 - if the Username does have the privilege
  • 0 - if the Username does not have the privilege
  • %Status - if CheckPriv call is reporting an error
  • Notes:

  • If Username is a user with the %All role, CheckPriv will return 1 even if the Object does not exist.
  • If the user calling CheckPriv is not the same as Username, the calling user must hold the %Admin_Secure:"U" privilege.

    Examples:

    • Do $SYSTEM.SQL.CheckPriv($username,"1,HHR.ProductionValues","s,i,u,d","USER",1)
    • Do $SYSTEM.SQL.CheckPriv("Miranda","3,SQLUser.Person","s","PRODUCT",0)
  • classmethod ClearStatistics(Scope As %Library.SmallInt = 1, ScopeArgument As %Library.String = "", ByRef Errors As %Library.String) [ Language = objectscript ]
    Clear SQL statistics for SQL statements in his namespace

    Parameter:
    Scope
    If Scope=1, clear the stats for all query plans in this namespace. This is the default Scope.
    If Scope=2, clear the stats for all query plans for the schema provided in ScopeArgument.
    If Scope=3, clear the stats for all query plans for the relation provided in ScopeArgument.
    If Scope=4, clear the stats for the query plan with the statement hash provided in ScopeArgument.
    ScopeArgument
    If Scope=2, the name of the schema for which to freeze the plans, if Scope=3, the name of the relation for which to freeze the plans.
    If Scope=3, the name of the relation needs to be in what we call internal qualified format. This is typically simply Schema.Tablename, but if tablename itself contains any "." characters, it needs to be in Schema_"."_$translate(Tablename,".",$Char(2)) format.
    If Scope=4, the value of the statement hash id. This is typically hash value like "3DgIqc72NS+Np6nybddb719NKb8=".
    Errors
    Passed by reference. Returns an array of error messages if there are any failures while freezing plans.

    Examples:

    • Do $SYSTEM.SQL.ClearStatistics(1,,.Errors)) // Clear SQL statistics for all statements in the current namespace
    • Do $SYSTEM.SQL.ClearStatistics(2,"XLT",.Errors)) // Clear SQL statistics for all statements for the current namespace for each statement that references a relation in the XLT schema.
    • Do $SYSTEM.SQL.ClearStatistics(3,"XLT.Person",.Errors)) // Clear SQL statistics for all statements for the current namespace for each statement that references the XLP.Person table.
    • Do $SYSTEM.SQL.ClearStatistics(4,"3DgIqc72NS+Np6nybddb719NKb8=",.Errors)) // Clear SQL statistics for statement identified by hash "3DgIqc72NS+Np6nybddb719NKb8=".
    classmethod CreateLinkedProcedure(dsn As %String, externalSchema As %String, externalProcedure As %String, localPackage As %String = "LinkedSchema", localClass As %String = "LinkedProcedure", localMethod As %String = "", localSqlName As %String = "", description As %String = "") as %Status [ Language = objectscript ]
    Create a linked process

    dsn - Data Source Name

    externalSchema - Schema name of the linked stored procedure of external source

    externalProcedure - External selected Stored Procedure name

    localPackage - New Stored Procedure's Package name. Default value is "LinkedSchema".

    localClass - New class name for the new Linked stored procedure. Default value is "LinkedProcedures"

    localMethod - Method name for the stored procedure. Default value is externalProcedure.

    localSqlName - New SQL name. Default value is externalProcedure.

    description - Description. Default value is empty

    classmethod CreateLinkedTable(dsn As %String, externalSchema As %String, externalTable As %String, primaryKeys As %String, localClass As %String = "User.LinkedClass", localTable As %String, ByRef columnMap As %String = "") as %Status [ Language = objectscript ]
    Create a linked table

    dsn - Data Source Name

    externalSchema - Schema name of the linked table of external source

    externalTable - The linked table name of external source

    primaryKeys - The fields for the primary keys of new created table.

    Multiple keys are seperated by comma. The primary keys should be specified as the "new class property name" if you do not use the original field name of the external source

    You at lease have to specify one field for this primaryKey.

    localClass - The new linked class name. The default value is "User.LinkedClass"

    localTable - The new table name for the linked class. Default value is localClass

    columnMap - The linked fields of the external table. Default is to map everthing as read-only columns if you don't specify anything in the map. Otherwise, specify the fields in the below format. columnMap("external field name") = $lb("new class property name","new sql field name","read-only"(1/0)) or use external field name as default values by specifying columnMap("external field name") = "". "new class property name" and "new sql field name" could be defined empty and "external field name" would be used as their default values "read only" default is on.

    Below gives a example about how to link a table from MySQL

    Use belows commands to create a table in MySQL

    in MySQL shell:

    create database test1;

    use test1;

    create table Person(PID int,name varchar(255));

    insert into Person(PID,name) values(1,"Cache")

    in Cache Terminal:

    $system.SQL.CreateLinkedTable(dsn,"","Person","PID,name","User.LinkedClass","LinkedTable","")

    would link all the fields of the table test1.Person from MySQL to the Cache class "User.LinkedTable"

    and use both PID and name as primiary keys

    classmethod CurrentSettings() as %Library.String [ Language = objectscript ]
    Displays all the current SQL settings to the current device.
    classmethod DATE(exp As %Library.String = "") as %Library.Date [ Language = objectscript ]
    DATE is a date/time function that returns the date portion of the given date or timestamp expression

    $SYSTEM.SQL.DATE(exp)

    exp
    An expression that is a logical %Library.Date, %Library.TimeStamp, %Library.PosixTime, %Library.Integer, or %Library.String value.
    If "" (null) is passed in, "" (null) is returned. If exp is not numeric, it is assumed the expression is in %Library.TimeStamp logical format. Note, that if a string value is passed in as exp, it is expected that the value is a logical %Library.TimeStamp format, and not $Horolog format. To convert $Horolog to DATE, use $SYSTEM.SQL.DATE(+$HOROLOG),
    classmethod DATEADD(datepart As %Library.String = "", val As %Library.Numeric = "", dateexp As %Library.String = "") as %Library.TimeStamp [ Language = objectscript ]
    DATEADD is a general date/time function that returns a date calculated by adding a certain number of date parts (such as hours or days) to a specified timestamp

    $SYSTEM.SQL.DATEADD(datepart,numeric-exp,dateexp)

    datepart
    The full name or abbreviation of a date or time part.
    The following date parts are supported for DATEADD
    year yy yyyy
    quarter qq q
    month mm m
    week wk ww
    dayofyear dy y
    day dd d
    hour hh
    minute mi n
    second ss s
    millisecond ms
    numeric-exp
    A numeric expression of any number type. The value is truncated to an integer. The value indicates the number of dateparts that will be added to dateexp.
    dateexp
    The date/time expression that will be modified.
    The dateexp parameter can be in any of the following formats, and may include or omit fractional seconds:
    • A %Library.Date logical value (+$H)
    • A %Library.PosixTime logical value
    • A %Library.TimeStamp logical value (YYYY-MM-DD HH:MM:SS)
    • A %Library.String (or compatible) value
    • The %Library.String (or compatible) value can be in any of the following formats:
      %Library.PosixTime logical value 99999,99999 ($H format)
      Sybase/SQL-Server-date Sybase/SQL-Server-time
      Sybase/SQL-Server-time Sybase/SQL-Server-date
      Sybase/SQL-Server-date (default time is 00:00:00)
      Sybase/SQL-Server-time (default date is 01/01/1900)
      Sybase/SQL-Server-date is one of these five formats:
      mmdelimiterdddelimiter[yy]yy
      dd Mmm[mm][,][yy]yy
      dd [yy]yy Mmm[mm]
      yyyy Mmm[mm] dd
      yyyy [dd] Mmm[mm]
      where delimiter is a slash (/), hyphen (-), or period (.).
      Sybase/SQL-Server-time represents one of these three formats:
      HH:MM[:SS:SSS][{AM|PM}]
      HH:MM[:SS.S]
      HH['']{AM|PM}
    If the year is given as two digits, a sliding window is checked to interpret the date. The system default for the sliding window can be set via the %DATE utility, which is documented only in the "Legacy Documentation" chapter in Using InterSystems Documentation.
    classmethod DATEDIFF(datepart As %Library.String = "", startdate As %Library.String = "", enddate As %Library.String = "") as %Library.Integer [ Language = objectscript ]
    DATEDIFF is a general date/time function that returns the interval between two dates

    $SYSTEM.SQL.DATEDIFF(datepart,startdate,enddate)

    datepart
    The date part in which the interval is to be measured.
    The following date parts are supported for DATEDIFF
    year yy yyyy
    month mm m
    week wk ww
    day dd d
    hour hh
    minute mi n
    second ss s
    millisecond ms
    startdate
    The starting date for the interval.
    enddate
    The ending date for the interval.
    Startdate is subtracted from enddate to determine how many datepart intervals are between the two dates.
    The startdate and enddate parameters can be in any of the following formats:
    • A %Library.Date logical value (+$H)
    • A %Library.PosixTime logical value
    • A %Library.TimeStamp logical value (YYYY-MM-DD HH:MM:SS)
    • A %Library.String (or compatible) value
    • The %Library.String (or compatible) value can be in any of the following formats, and may include or omit fractional seconds:

    • 99999,99999 ($HOROLOG format)
      Sybase/SQL-Server-date Sybase/SQL-Server-time
      Sybase/SQL-Server-time Sybase/SQL-Server-date
      Sybase/SQL-Server-date (default time is 00:00:00)
      Sybase/SQL-Server-time (default date is 01/01/1900)
    • Sybase/SQL-Server-date is one of these five formats:

    • mmdelimiterdddelimiter[yy]yy
      dd Mmm[mm][,][yy]yy
      dd [yy]yy Mmm[mm]
      yyyy Mmm[mm] dd
      yyyy [dd] Mmm[mm]
      where delimiter is a slash (/), hyphen (-), or period (.).
    • Sybase/SQL-Server-time represents one of these three formats:

    • HH:MM[:SS:SSS][{AM|PM}]
      HH:MM[:SS.S]
      HH['']{AM|PM}
    If the year is given as two digits, a sliding window is checked to interpret the date. The system default for the sliding window can be set via the %DATE utility, which is documented only in the "Legacy Documentation" chapter in Using InterSystems Documentation.
    classmethod DATENAME(datepart As %Library.String = "", dateexp As %Library.String = "") as %Library.String [ Language = objectscript ]
    DATENAME is a general date/time function that returns a CHARACTER STRING containing the name of the specified date part of a date/time value.

    $SYSTEM.SQL.DATENAME(datepart,dateexp)

    datepart
    The type of date part that the returned value will represent.
    The following date parts are supported for DATENAME
    year yy yyyy
    quarter qq q
    month mm m
    week wk ww
    weekday dw
    dayofyear dy y
    day dd d
    hour hh
    minute mi n
    second ss s
    millisecond ms
    dateexp
    A date/time expression from which the date part is to be returned.
    The dateexp parameter can be in any of the following formats:
    • A %Library.Date logical value (+$H)
    • A %Library.PosixTime logical value
    • A %Library.TimeStamp logical value (YYYY-MM-DD HH:MM:SS)
    • A %Library.String (or compatible) value
    • The %Library.String (or compatible) value can be in any of the following formats, and may include or omit fractional seconds:

    • 99999,99999 ($HOROLOG format)
      Sybase/SQL-Server-date Sybase/SQL-Server-time
      Sybase/SQL-Server-time Sybase/SQL-Server-date
      Sybase/SQL-Server-date (default time is 00:00:00)
      Sybase/SQL-Server-time (default date is 01/01/1900)
    • Sybase/SQL-Server-date is one of these five formats:

    • mmdelimiterdddelimiter[yy]yy
      dd Mmm[mm][,][yy]yy
      dd [yy]yy Mmm[mm]
      yyyy Mmm[mm] dd
      yyyy [dd] Mmm[mm]
      where delimiter is a slash (/), hyphen (-), or period (.).
    • Sybase/SQL-Server-time represents one of these three formats:

    • HH:MM[:SS:SSS][{AM|PM}]
      HH:MM[:SS.S]
      HH['']{AM|PM}
    If the year is given as two digits, a sliding window is checked to interpret the date. The system default for the sliding window can be set via the %DATE utility, which is documented only in the "Legacy Documentation" chapter in Using InterSystems Documentation.
    classmethod DATEPART(datepart As %Library.String = "", dateexp As %Library.String = "") as %Library.Integer [ Language = objectscript ]
    DATEPART is a general date/time function that returns an INTEGER representing the specified date/time part of the specified date/time expression.

    $SYSTEM.SQL.DATEPART(datepart,dateexp)

    datepart
    The type of date part that the returned value will represent.
    The following date parts are supported for DATEPART
    year yy yyyy
    quarter qq q
    month mm m
    week wk ww
    weekday dw
    dayofyear dy y
    day dd d
    hour hh
    minute mi n
    second ss s
    millisecond ms
    sqltimestamp sts
    The sqltimestamp (abbreviated sts) datepart value is for use only with DATEPART. Do not attempt to use this parameter value in other contexts
    dateexp
    A date/time expression from which the date part is to be returned.
    dateexp must contain a value of type datepart.
    The dateexp parameter can be in any of the following formats:
    • A %Library.Date logical value (+$H)
    • A %Library.PosixTime logical value
    • A %Library.TimeStamp logical value (YYYY-MM-DD HH:MM:SS)
    • A %Library.String (or compatible) value
    • The %Library.String (or compatible) value can be in any of the following formats, and may include or omit fractional seconds:

    • 99999,99999 ($HOROLOG format)
      Sybase/SQL-Server-date Sybase/SQL-Server-time
      Sybase/SQL-Server-time Sybase/SQL-Server-date
      Sybase/SQL-Server-date (default time is 00:00:00)
      Sybase/SQL-Server-time (default date is 01/01/1900)
    • Sybase/SQL-Server-date is one of these five formats:

    • mmdelimiterdddelimiter[yy]yy
      dd Mmm[mm][,][yy]yy
      dd [yy]yy Mmm[mm]
      yyyy Mmm[mm] dd
      yyyy [dd] Mmm[mm]
      where delimiter is a slash (/), hyphen (-), or period (.).
    • Sybase/SQL-Server-time represents one of these three formats:

    • HH:MM[:SS:SSS][{AM|PM}]
      HH:MM[:SS.S]
      HH['']{AM|PM}
    If the year is given as two digits, a sliding window is checked to interpret the date. The system default for the sliding window can be set via the %DATE utility, which is documented only in the "Legacy Documentation" chapter in Using InterSystems Documentation.
    classmethod DAYNAME(dateexp As %Library.String = "") as %Library.String [ Language = objectscript ]
    DAYNAME is a date/time function that returns a character string containing the name of the day in a given date or datetime expression.

    $SYSTEM.SQL.DAYNAME(dateexp)

    dateexp
    An expression that is a logical %Library.Date, %Library.TimeStamp, or %Library.PosixTime value.
    If the year is given as two digits, a sliding window is checked to interpret the date. The system default for the sliding window can be set via the %DATE utility, which is documented only in the "Legacy Documentation" chapter in Using InterSystems Documentation.
    classmethod DAYOFMONTH(dateexp As %Library.String = "") as %Library.Integer [ Language = objectscript ]
    DAYOFMONTH is a date/time function that returns an integer from 1 to 31 that corresponds to the day of the month in a given date expression.

    $SYSTEM.SQL.DAYOFMONTH(dateexp)

    dateexp
    An expression that is a logical %Library.Date, %Library.TimeStamp, or %Library.PosixTime.
    classmethod DAYOFWEEK(dateexp As %Library.String = "") as %Library.Integer [ Language = objectscript ]
    DAYOFWEEK is a date/time function that returns an integer from 1 to 7 that corresponds to the day of the week in a given date expression.

    $SYSTEM.SQL.DAYOFWEEK(dateexp)

    dateexp
    An expression that is a logical %Library.Date value, %Library.TimeStamp, %Library.PosixTime, or an $Horolog value.
    The returned values represent these days: 1 - Sunday, 2 - Monday, 3 - Tuesday, 4 - Wednesday, 5 - Thursday, 6 - Friday, 7 - Saturday
    The default is that Sunday is the first day of the week.
    This default can be overridden by specifying SET ^%SYS("sql","sys","day of week")=n, where n values are 1=Monday through 7=Sunday.
    Thus, to reset the default specify SET ^%SYS("sql","sys","day of week")=7.
    The day of week setting can also be defined on a per-namespace basis by adding an additional namespace subscript, for example:
    SET ^%SYS("sql","sys","day of week","USER")=n, where n values are 1=Monday through 7=Sunday.
    InterSystems IRIS also supports the ISO 8601 standard for determining the day of the week, week of the year, and other date settings. This standard is principally used in European countries. The ISO 8601 standard begins counting the days of the week with Monday. To activate ISO 8601, SET ^%SYS("sql","sys","week ISO8601")=1; to deactivate, set it to 0. If week ISO8601 is activated and "day of the week" is undefined or set to the default (7=Sunday), the ISO 8601 standard overrides the default. If "day of the week" is set to any other value, it overrides week ISO8601 for DAYOFWEEK.
    classmethod DAYOFYEAR(dateexp As %Library.String = "") as %Library.Integer [ Language = objectscript ]
    DAYOFYEAR is a date/time function that returns an integer from 1 to 366 that corresponds to the day of the year in a given date expression.

    $SYSTEM.SQL.DAYOFYEAR(dateexp)

    dateexp
    An expression that is a logical %Library.Date value, %Library.TimeStamp, or %Library.PosixTime value.
    classmethod DDLImport(DDLMode As %Library.String, SQLUser As %Library.String, infile As %Library.String, outfile As %Library.String, nosup As %Library.Boolean = 0, nosupfile As %Library.String, deos As %Library.String, errpause As %SmallInt = 5, runtimemode As %String = "Logical") as %Library.String [ Language = objectscript ]
    Import a DDL/DML script file.

    Parameters:
    DDLMode
    Vendor from which the script file originated. This parameter is required. Supported values are:
    • IRIS
    • CACHE
    • FDBMS
    • Informix
    • Interbase
    • MSSQL
    • MSSQLServer - same as MSSQL
    • MySQL
    • Oracle
    • Sybase
    SQLUser
    This parameter is deprecated and no longer used. The owner of new classes is always defined as the $Username of the process that executed the DDL statement
    infile
    The full path name of the script file to import. This parameter is required. A $list value may also be passed in with the filename and the TranslateTable to use for the file. The first element is the file name and the second element is the TranslateTable for the input stream file. This is only supported for DDLMode MSSQL, Sybase, Informix, or MySQL.
    outfile
    The full path name of the file to report errors in. This parameter is Optional. Default is the same as the infile with a _Errors.log extension.
    nosup
    TRUE(1)/FALSE(0) flag. Determines if unsupported statements from the script file should be recorded in the nosupfile. This parameter is optional, 0 is the default.
    nosupfile
    If nosup is true, the name of the file to log the unsupported statements in. Default is the same as the infile with a _Unsupported.log extension. This parameter is optional.
    deos
    End of statement delimiter. Will default to an appropriate value based on the value of %DDLMode. This parameter is optional.
    errpause
    Number of seconds to pause after an error occurs. The default is 5 seconds. This parameter is optional.
    runtimemode
    Which selectmode to run the imported statement in, ODBC, DISPLAY, or LOGICAL. This only applies when DDLMode=IRIS. If any value other than ODBC or DISPLAY is specified, LOGICAL mode is used. This parameter is optional.

    When DDLMode=IRIS, the following statements are supported:

    • CREATE ...
    • DROP ...
    • TRUNCATE TABLE ...
    • ALTER ...
    • INSERT ...
    • UPDATE ...
    • DELETE ...
    • SET OPTION ...
    • GRANT ...
    • REVOKE ...

    Examples:

    • Do $SYSTEM.SQL.DDLImport("Sybase","_SYSTEM","C:\PT\Patient.sql")
    • Do $SYSTEM.SQL.DDLImport("Oracle","DAVE","C:\DDT\all_tables.sql",all.log,0,"",";",2)
    classmethod DDLImportDir(DDLMode As %Library.String = "", directory As %Library.String = "", logfile As %Library.String = "", eosDelimiter As %Library.String = "") [ Language = objectscript ]
    Import all DDL/DML script file in a given directory. All files with the extension .sql in the directory will be imported.

    Parameters:
    DDLMode
    Vendor from which the script file originated. This parameter is required. Supported values are:
    • Informix
    • MSSQL
    • MSSQLServer - same as MSSQL
    • Sybase
    directory
    The full path name of the directory to import. This parameter is required.
    logfile
    The full path name of the file to report errors in. This parameter is Optional. Default is DDLImportDir.log in the directory loaded. If this parameter value is 1, a separate log file will be generated for each file loaded. The name of the log file will be the same as the file imported, but with the extension .log instead of .sql.
    eosDelimiter
    End of statement delimiter. Will default to an appropriate value based on the value of %DDLMode. This parameter is optional.

    Examples:

    • Do $SYSTEM.SQL.DDLImportDir("Informix","C:\Work\db1\,"C:\Work\db1\import.log",";")
    • Do $SYSTEM.SQL.DDLImportDir("Informix","C:\Work\db1\,1,";")
    classmethod DefaultSchema() as %Library.String [ Language = objectscript ]
    Return the default schema name for the current process in the current namespace

    Example:

    Set CurrentSchema = $SYSTEM.SQL.DefaultSchema()
    
    classmethod DropAll() as %Integer [ Language = objectscript ]
    This method closes all the open ODBC/JDBC Gateway connections and unloads the SQL Gateway shared library.
    classmethod DropTable(tablename As %Library.String, deldata As %Library.Boolean = 0, ByRef SQLCODE As %Library.Integer, ByRef %msg As %Library.String) as %Library.String [ Language = objectscript ]
    This entry point can be used to delete a table definition.

    Parameters:
    tablename
    Name of the SQL table to delete. The name may be qualified with a schema name: Medical.Patient. If the schema name is omitted, the default schema is used.
    deldata
    TRUE(1)/FALSE(0) flag which determine if the table's data is to be deleted or not. If deldata="" or undefined, use system flag to determine if data should be deleted.
    SQLCODE
    Passed by reference. Returns SQLCODE. Contains 0 (success) or number < 0 (error).
    %msg
    Passed by reference. If SQLCODE<0, contains error message.

    Examples:

    • Do $SYSTEM.SQL.DropTable("MedLab.Patient",1,.SQLCODE,.%msg)
    • Do $SYSTEM.SQL.DropTable("IscPerson",1,.SQLCODE,.%msg) ; Deletes SQLUser.IscPerson
    classmethod DropView(viewname As %Library.String, ByRef SQLCODE As %Library.Integer, ByRef %msg As %Library.String) as %Library.String [ Language = objectscript ]
    This entry point can be used to delete a view definition.

    Parameters:
    viewname
    Name of the SQL view to delete. The name may be qualified with a schema name: Medical.PatientView If the schema name is omitted, the default schema is used.
    SQLCODE
    Passed by reference. Returns SQLCODE. Contains 0 (success) or number < 0 (error)
    %msg
    Passed by reference. If SQLCODE<0, contains error message.

    Examples:

    • Do $SYSTEM.SQL.DropView("MedLab.PatientView",.SQLCODE,.%msg)
    • Do $SYSTEM.SQL.DropView("IscPersonView",.SQLCODE,.%msg) ; Deletes SQLUser.IscPerson
    classmethod Execute(ByRef SQL As %String(MAXLEN=""), SelectMode As %String = {$zu(115, 5)}, Dialect As %String = "", ObjectSelectMode As %Integer = 0) as %SQL.StatementResult [ Language = objectscript ]
    Execute an SQL statement and return the result object.
    Parameters:
    SQL
    SQL statement to execute. This can be an array of SQL statement lines with the base node set to the number of lines or it can be a single string..
    SelectMode
    The statement SELECTMODE - LOGICAL, ODBC or DISPLAY.
    Can also be specified as 0, 1, or 2.
    Dialect
    The SQL dialect used for this SQL statement. Valid values are IRIS, MSSQLSERVER, MSSQL, and SYBASE. The default is IRIS. Support for MSSQLSERVER and SYBASE dialects is limited to a subset of the TSQL grammar supported by the InterSystems IRIS TSQL language mode.
    ObjectSelectMode
    The statement %ObjectSelectMode value - 0 or 1. Refer to %SQL.Statement for more information on ObjectSelectMode.

    Examples:

    • set result=$SYSTEM.SQL.Execute("select top 5 name,dob,ssn from sample.person order by name")
    • set result=$SYSTEM.SQL.Execute("select top 5 name,dob,ssn,home_street,,home_city + ', ' + home_state + ' ' + home_zip from sample.person order by name",1,"MSSQL")
    • set sql=2,sql(1)="select top 5 name,dob,ssn from sample.person"
      set sql(2)=" order by name"
      set result=$SYSTEM.SQL.Execute(.sql)
    • set result=$SYSTEM.SQL.Execute("")
    • set result=$SYSTEM.SQL.Execute("insert into sample.person (name,dob,ssn) values ('Doe,John Q.','02/29/1952','111-22-3333')",2)
    classmethod ExecuteCachedQuery(pCQName As %String = "", pNumRowsToDisplay As %Integer = 10, pArgs... As %String) [ Language = objectscript ]
    Execute an xDBC or %SQL.Statement Cached Query from the command line for debugging purposes.

    Parameters:
    pCQName
    Name of the cached query class to execute. This can be the entire class name, like %sqlcq.SAMPLES.cls5, or the short version of the name like cls5.
    pNumRowsToDisplay
    The number of rows for the select query to output. The default is 10.
    pArgs...
    The input arguments to the query. If the statement has input arguments and you don't pass them in here, the caller will be promoted for the input values.

    Examples:

    • SAMPLES>do $SYSTEM.SQL.ExecuteCachedQuery("%sqlcq.SAMPLES.cls8",2) Device: Right margin: 225 => Executing xDBC Cached Query: %sqlcq.SAMPLES.cls8 Query text: select Name , SSN , DOB from Sample . Person where Age > :%qpar(1) Result Metadata: Column: 1 Sample.Person.Name VARCHAR(50) NOT NULLABLE Column: 2 Sample.Person.SSN VARCHAR(50) NOT NULLABLE isUnique isKeyColumn Column: 3 Sample.Person.DOB DATE NULLABLE Parameter Metadata: Parameter: 1 %qpar(1) INTEGER NULLABLE This statement has 1 parameter Enter the value for parameter '1': 20 SQLCODE(Open)=0 Row 1: --- Cursor Variables --- %qscd(1,1) = 1 %qscd(1,3) = 0 %qscd(1,4) = %qscd(1,5) = 20 %qscd(1,6) = 12 %qscd(1,7) = $lb("","Nagel,Molly B.","894-47-5000",54195,$lb("7425 Main Place","Newton","MN",81696),$lb("5436 Oak Court","Reston","VT",55529),"",$lb("Red","Yellow")) %qscd(1,8) = 54195 %qscd(1,9) = 25 --- Output Variables --- %datax(1,1) = Nagel,Molly B. %datax(1,2) = 894-47-5000 %datax(1,3) = 1989-05-19 Row 2: --- Cursor Variables --- %qscd(1,1) = 2 %qscd(1,3) = 0 %qscd(1,4) = %qscd(1,5) = 20 %qscd(1,6) = 16 %qscd(1,7) = $lb("","Ubertini,Angelo Y.","428-10-1982",54168,$lb("7812 Main Street","Washington","AZ",18420),$lb("2848 Second Blvd","Miami","TX",97018),"","") %qscd(1,8) = 54168 %qscd(1,9) = 25 --- Output Variables --- %datax(1,1) = Ubertini,Angelo Y. %datax(1,2) = 428-10-1982 %datax(1,3) = 1989-04-22 32 rows retrieved (2 displayed) in 2.649951 seconds SQLCODE(LastFetch)=100 SQLCODE(Close)=0
    • SAMPLES>do $SYSTEM.SQL.ExecuteCachedQuery(".cls7") Device: Right margin: 225 => Executing %SQL.Statement Cached Query: %sqlcq.SAMPLES.cls7 Query text: DELETE FROM sample . person WHERE age IN ( ? , ? , ? ) Parameter Metadata: Parameter: 1 %qpar(1) INTEGER NOT NULLABLE Parameter: 2 %qpar(2) INTEGER NOT NULLABLE Parameter: 3 %qpar(3) INTEGER NOT NULLABLE This statement has 3 parameters Enter the value for parameter '1': 33 Enter the value for parameter '2': 44 Enter the value for parameter '3': 55 SQLCODE(%Execute)=0 1 rows affected by INSERT/UPDATE/DELETE or other statement. Execution time: 4.201253 seconds

    Notes:

    • - Only cached queries created through ODBC, JDBC, or %SQL.Statement are supported
    • - The cached query must have been created with a client from version 5.2 or newer
    • - SQL Privilege checking is NOT performed for $SYSTEM.SQL.ExecuteCachedQuery
    • - As this is intended as a developer debugging tool, there is no locking of the cached query to prevent a Purge of the cached query during $SYSTEM.SQL.ExecuteCachedQuery.
    classmethod Export(Schema As %Library.String, Table As %Library.String, File As %Library.String, FileOpenParam As %Library.String = "WNS", Users As %Library.Boolean = 1, Roles As %Library.Boolean = 1, Privileges As %Library.Boolean = 1, SQLSystemPrivileges As %Library.Boolean = 1) as %Library.Status [ Language = objectscript ]
    Export a SQL DDL/DML script file containing User definitions, Role definitions, and/or Privileges.

    Parameters:
    Schema
    Name of the schema in the current namespace to export the privileges for. Use "*" to specify the export of SQL Privileges for all schemas in the current namespace. The default is "*". Note that when "*" is specified, '%' schemas (such as %Dictionary) are not exported. To export privileges for tables in a schema that begins with '%' you must explicitly specify that schema name in Schema.
    Table
    Name of the table/view in the specified schema to export the privileges for. Use "*" to specify the export of SQL Privileges for all table/s views in the specified schema(s). The default is "*". Note that if you "*" for Schema the export will behave as if you entered "*" for Table as well. For example there is no mechanism for exporting the Person table/view in each schema in the namespace.
    File
    Name of the file to export the SQL statement to.
    FileOpenParam
    Parameters to use when opening the File. The default is "WNS".
    Users
    1/0 flag. Specify 1 to export the User definition. The default is 1.
    Roles
    1/0 flag. Specify 1 to export the Role definition, and the GRANT statements to assign the Roles to the Users and Roles they have been granted to. The default is 1.
    Privileges
    1/0 flag. Specify 1 to export the Table and View privileges for the tables and views specified in the Schema/Table specification. The default is 1.
    SQLSystemPrivileges
    1/0 flag. Specify 1 to export the SQL System privileges defined in the current namespace for the users and roles. The default is 1.

    Examples:

    • Do $SYSTEM.SQL.Export("Sample","*","C:\PT\Sample.sql","WNS",0,0,1,1)
    • Do $SYSTEM.SQL.DDLImport("*","*","C:\DDT\UsersAndRoles.sql","WNS",1,1,0,0)

    The method returns a Status Code.

    A file created via $SYSTEM.SQL.Export() can be imported using one of:

    • Do $SYSTEM.SQL.DDLImport("IRIS",...)
    • Do $SYSTEM.SQL.IRIS()

    The Export() method will not export the following users and roles -

    Users:
    SuperUser, Admin, UnknownUser, %System, CSPSystem, _SYSTEM, _PUBLIC
    Roles:
    %All, %Developer, %Manager, %Operator, %SQL, %LegacyTerminal, %LegacyCacheDirect, %LegacySQL
    classmethod ExportAllSQLStatements(Filename As %Library.String = "") as %Library.Status [ Language = objectscript ]
    Exports all SQL Statement Index entries in this namespace, including query plans. Generated file can be loaded using $SYSTEM.SQL.ImportStatement().
    The main reason to export/import an SQL Statement entry is to move a frozen plan from one location to another. Other than moving a frozen plan, there is not much benefit of moving an SQL Statement definition from one location to another. When exporting SQL Statement definitions, the Locations (routines) the SQL Statement is defined in is not exported. This is because it is possible the Locations are different or don't exist on the target system. Recompiling the class/routines that contain the SQL Statement on the target system will redeine the Location entries for the SQL Statement definition.
    Any SQL Statements the current user does not have privilege to run will not be exported.

    Parameter:
    Filename
    Name of the file to output the SQL Statement definitions to.

    Examples:

    • Do $SYSTEM.SQL.ExportAllSQLStatements("C:\MyAllStatements.xml") // Exports all SQL Satements
    classmethod ExportSQLStatement(Filename As %Library.String = "", Hash As %Library.String = "") as %Library.Status [ Language = objectscript ]
    Export an SQL Statement Index entry, including query plan. Generated file can be loaded using $SYSTEM.SQL.ImportStatement().
    The main reason to export/import an SQL Statement entry is to move a frozen plan from one location to another. Other than moving a frozen plan, there is not much benefit of moving an SQL Statement definition from one location to another. When exporting SQL Statement definitions, the Locations (routines) the SQL Statement is defined in is not exported. This is because it is possible the Locations are different or don't exist on the target system. Recompiling the class/routines that contain the SQL Statement on the target system will redeine the Location entries for the SQL Statement definition.
    If the current user is not privileged to execute this SQL Statement, a privilege error will be returned and the export will not occur.

    Parameter:
    Filename
    Name of the file to output the SQL Statement definition to.
    Hash
    SQL Statement definition hash, used as the ID of the SQL Statement Definition index entry

    Examples:

    • Do $SYSTEM.SQL.ExportSQLStatement("C:\MyStatement.xml","Kod99B0VFOn/aXQ9PyRGfb64q04=") // Exports SQL Satement with ID hash of 'Kod99B0VFOn/aXQ9PyRGfb64q04='
    classmethod ExportTuneStats(pFilename As %Library.String, pSchemaFilter As %Library.String = "", pTableFilter As %Library.String = "", pDisplay As %Library.Boolean = 1) as %Library.Status [ Language = objectscript ]
    Export extentsize and selectivity for tables/fields to an XML file. Generated file can be loaded using $SYSTEM.SQL.ImportTuneStats().

    Parameter:
    pFilename
    Name of the file to output the table(s) tuning statistics to.
    pSchemaFilter
    Filter to limit the schemas output. The default is "", which means there is no filter applied and all schemas in the namespace are exported. pSchemaFilter uses '_' to signify any single character, '*' to signify 0 through N characters, and ' to signify NOT.
    pTableFilter
    Filter to limit the tables output. The default is "", which means there is no filter applied and all tables in the specified schemas are exported. pTableFilter uses '_' to signify any single character, '*' to signify 0 through N characters, and ' to signify NOT.
    pDisplay
    TRUE(1)/FALSE(0) flag. Displays progress messages to the current device if TRUE. The default is TRUE (1).

    Examples:

    • Do $SYSTEM.SQL.ExportTuneStats("C:\AllStats.xml") // Exports TuneTable Statistics for all schemas/tables in the current namespace
    • Do $SYSTEM.SQL.ExportTuneStats("C:\SampleStats.xml","Sample") // Exports TuneTable Statistics for all Sample.* tables in the current namespace
    • Do $SYSTEM.SQL.ExportTuneStats("C:\SamplePStats.xml","Sample","P*") // Exports TuneTable Statistics for all Sample.P* in the current namespace
    • Do $SYSTEM.SQL.ExportTuneStats("C:\SamplePersonStats.xml","Sample","Person") // Exports TuneTable Statistics for table Sample.Person in the current namespace
    classmethod FDBMS() as %Library.String [ Language = objectscript ]
    Import a FDBMS DDL script file.
    classmethod FLOOR(val As %Library.Numeric = "") as %Library.Integer [ Language = objectscript ]
    FLOOR is a numeric function that returns the largest integer less than or equal to a given numeric expression

    $SYSTEM.SQL.FLOOR(dateexp)

    numeric-exp
    A number whose floor is to be calculated.
    classmethod FreezePlans(Action As %Library.SmallInt = 1, Scope As %Library.SmallInt = 1, ScopeArgument As %Library.String = "", ByRef Errors As %Library.String) [ Language = objectscript ]
    Freeze or Unfreeze plans or SQL statements in this namespace

    Parameter:
    Action
    If Action=0, Unfreeze all plans within the Scope that are marked Frozen/Explicit or Frozen/Upgrade.
    If Action=1, Freeze all plans within the Scope that are marked Unfrozen or Frozen/Upgrade. This is the default Action.
    If Action=2, Unfreeze all plans within the Scope that are marked Frozen/Upgrade.
    Scope
    If Scope=1, perform the Action for all query plans in this namespace. This is the default Scope.
    If Scope=2, perform the Action for all query plans for the schema provided in ScopeArgument.
    If Scope=3, perform the Action for all query plans for the relation provided in ScopeArgument.
    If Scope=4, perform the Action for the query plan with the statement hash provided in ScopeArgument.
    ScopeArgument
    If Scope=2, the name of the schema for which to freeze the plans, if Scope=3, the name of the relation for which to freeze the plans.
    If Scope=3, the name of the relation needs to be in what we call internal qualified format. This is typically simply Schema.Tablename, but if tablename itself contains any "." characters, it needs to be in Schema_"."_$translate(Tablename,".",$Char(2)) format.
    If Scope=4, the value of the statement hash id. This is typically hash value like "3DgIqc72NS+Np6nybddb719NKb8=".
    Errors
    Passed by reference. Returns an array of error messages if there are any failures while freezing plans.

    Examples:

    • Do $SYSTEM.SQL.FreezePlans(1,1,,.Errors) // Freezes all SQL statement plans in the current namespace
    • Do $SYSTEM.SQL.FreezePlans(1,2,"XLT",.Errors) // Freezes all SQL statement plans in the current namespace for each statement that references a relation in the XLT schema.
    • Do $SYSTEM.SQL.FreezePlans(1,3,"XLT.Person",.Errors) // Freezes all SQL statement plans in the current namespace for each statement that references the XLP.Person table.
    • Do $SYSTEM.SQL.FreezePlans(1,4,"3DgIqc72NS+Np6nybddb719NKb8=",.Errors) // Freezes SQL statement plan for statement identified by hash "3DgIqc72NS+Np6nybddb719NKb8=".
    • Do $SYSTEM.SQL.FreezePlans(0,1,,.Errors) // Unfreezes all SQL statement plans in the current namespace
    • Do $SYSTEM.SQL.FreezePlans(2,1,,.Errors) // Unfreezes all SQL statement plans in the current namespace that were marked Frozen/Upgrade.
    • Do $SYSTEM.SQL.FreezePlans(0,2,"XLT",.Errors) // Unfreezes all SQL statement plans in the current namespace for each statement that references a relation in the XLT schema.
    • Do $SYSTEM.SQL.FreezePlans(0,3,"XLT.Person",.Errors) // Unfreezes all SQL statement plans in the current namespace for each statement that references the XLP.Person table.
    • Do $SYSTEM.SQL.FreezePlans(2,3,"XLT.Person",.Errors) // Unfreezes all SQL statement plans in the current namespace for each statement that references the XLP.Person table and that were marked Frozen/Upgrade.
    • Do $SYSTEM.SQL.FreezePlans(0,4,"3DgIqc72NS+Np6nybddb719NKb8=",.Errors)) // Unfreezes SQL statement plan for statement identified by hash "3DgIqc72NS+Np6nybddb719NKb8=".
    classmethod GetAutoCommit() as %Integer [ Language = objectscript ]
    Return the current process's Transaction Commit Mode value. Possible values are:

    0NO AUTO TRANSACTION
    1AUTO COMMIT ON (Default)
    2AUTO COMMIT OFF
    classmethod GetBitmapFriendlyCheck() as %Library.Boolean [ Language = objectscript ]
    Returns the current system-wide setting of the BitmapFriendlyCheck flag.
    See SetBitmapFriendlyCheck() for more information about this setting.

    Returns:

    Boolean value:

    1 means the class compiler will check to make sure the type of ID of the class is a positive integer if there is a bitmap index defined for the class and the class uses %Storage.SQL.
    0 (the default), means the class compiler will not perform this check and no error will be returned if the class contains a bitmap index and does not have a positive integer ID type.

    classmethod GetCollectionProjection() as %Integer [ Language = objectscript ]
    Return the CollectionProjection setting. Possible values are:

    0Do not project collections as columns if also projected as child table (DEFAULT)
    1Project all collections as columns
    classmethod GetColumns(tablename As %String = "", ByRef byName As %String, ByRef byNumber As %String, skipHiddenFields As %Boolean = 0) as %Boolean [ Language = objectscript ]
    Given a table name, return a list of columns by name with the column number, and a list of columns sorted by column number with the name.

    Parameters:
    tableName
    Name of the table to return the columns for. Name is expected to be in the format Schema.Tablename If the name is unqualified, the default schema will be used.
    byName
    Passed By Reference. Returns columns ordered by column name with SqlColumnNumber as data. For example: byName("Id")=1,byName("Name")=2
    byNumber
    Passed By Reference. Returns columns ordered by SqlColumnNumber with column name as data. For example: byName(1)="Id",byName(2)="Name"
    skipHiddenFields
    Passed By Value. Default is 0. If TRUE, do not include any SQL hidden columns in the byName and byNumber output arrays. SQL fields are defined as hidden if they are projected by a property defined as private, a RowID field defined as SqlRowIDPrivate, a RowID field for a linked table, a serial field that is not a collection and the storage structure is known, the %%CLASSNAME field, or a list or array collection property projected as a child table.
    Returns: A %Boolean value. 1 if the columns were returned successfully, 0 if there was no such table.
    classmethod GetCompileMode() as %Library.String [ Language = objectscript ]
    Function returns the current Compile Mode setting, either Deferred or Immediate.
    classmethod GetIdentityInsert() as %Integer [ Language = objectscript ]
    Return the current IDENTITY_INSERT option value. Possible values are:

    0IDENTITY cannot be set
    1IDENTITY can be set

    classmethod GetIsolationMode() as %Integer [ Language = objectscript ]
    Return the current process's Transaction Isolation Mode value. Possible values are:

    0 - READ UNCOMMITTED (Default)
    1 - READ COMMITTED
    3 - READ VERIFIED
    classmethod GetLockThreshold() as %Integer [ Language = objectscript ]
    Return the current Lock Threshold setting. The value returned is an integer that is the number of row locks to acquire before escalating to a table lock. This is a system wide setting that is in effect for all processes.
    classmethod GetLockTimeout() as %Integer [ Language = objectscript ]
    Return the current system Lock Timeout value as defined in the configuration settings. Note, this may be different than the lock timeout for the current process.
    classmethod GetMapSelectability(pTablename As %Library.String = "", pMapname As %Library.String = "") as %Library.String [ Language = objectscript ]
    This entrypoint is used to determine if an SQL Map definition is selectable by the SQL Query Optimizer or not

    Parameters:
    pTablename
    Name of the table to check.
    pTablename can be qualified or unqualified. If unqualified, the default schema is applied.
    pMapname
    Name of the SQL Map in the table to check the selectable for.

    Returns: The method returns 1 if the map is selectable. If the map is not selectable, 0 is returned. If the Selectability of the map cannot be determined, a message string will be returned.

    Note:

      A return of 1 by this function does not necessarily mean the map exists, just that the map's selectability has not been set to 0.
      Also, this feature checks the selectability for the map in the current namespace only. If this table is mapped to multiple namespaces, and the index needs to be built in each namespace, SetMapSelectability should be called in each namespace the index is to be built in. GetMapSelectability should be checked in each namespace the table is mapped to.

    Examples:

    • Write $SYSTEM.SQL.GetMapSelectability("Sample.Person","NameIndex")
    classmethod GetProcessLockTimeout() as %Integer [ Language = objectscript ]
    Return the Lock Timeout value for the current process.
    classmethod GetROWID() as %Library.String [ Language = objectscript, SQLProc = SQL_GetROWID ]
    Function returns the current contents of the %ROWID variable. It can be called after INSERT to get %ROWID value of the row inserted. This method can also be called as a Stored Procedure named %SYSTEM.SQL_GetROWID()
    classmethod GetSQLFunctionArgConversion() as %Boolean [ Language = objectscript ]
    Get the current setting of the system wide flag for controlling if SQL Functions perform ODBCToLogical/DisplayToLogical on SQL Function input arguments.

    Parameters:
    flag
    TRUE(1)/FALSE(0) If flag is FALSE(0) (the default), SQL will not convert input arguments for SQL Functions from Odbc/Display to Logical format. If TRUE(1), SQL will convert input arguments for SQL Functions from Odbc/Display to Logical format if needed.
    pStatus
    Status Code reports the success or failure of this API call
    Returns:

    Current value of the SQLFunctionArgConversion setting

    Examples:

    • Set return = $SYSTEM.SQL.GetSQLFunctionArgConversion()
    NOTES:
    - This is a system-wide setting.
    classmethod GetSQLStatsFlag(flagType As %Integer = "", returnActionFlag As %Integer = 0, ByRef ptInfo As %ArrayOfObjects) as %Library.Integer [ Language = objectscript ]

    Method: GetSQLStatsFlag [SQL: StatsSQL_GetSQLStatsFlag] Purpose: This method gets the flag that controls whether or not we collect SQL Statistics for each SQL Query execution Get the current value of the SQLStats-flag for the given 'flagType'. The SQLStats-flag (System/Job) controls whether or not SQL Statistics are collected for each SQL Query execution, and which performance statistics to be collected. The SQLStats-flag is a colon (:) delimited string comprised of the following individual components: SQLStats-flag={action-flag}:{collect-flag}:{condition-flag}:{condition-value}:{terminate-flag} RULES: When (flagType=""), whether to use the SQLStats-flag (System) or the SQLStats-flag (Process/Job) is determined by the following rules: IF {action-flag} (Process/Job) = 0, then use SQLStats-flag (System) ELSE use SQLStats-flag (Process/Job) Invocation: This method can be invoked in the following ways: Object Script: $SYSTEM.SQL.GetSQLStatsFlag(...) ##class(%SYS.PTools.StatsSQL).GetSQLStatsFlag(...) SQL: SELECT %SYS_PTools.StatsSQL_GetSQLStatsFlag(...) Examples: The following examples shows the use of this method: #1 Get the current value of the SQLStats-flag for the Job/System Flag based on SQLStats-flag Rules: set SQLStatsFlag=##class(%SYS.PTools.StatsSQL).GetSQLStatsFlag("") Parameters: flagType - "" = Job/System Flag based on SQLStats-flag Rules [DEFAULT] 0 = System Flag 1 = Process/Job Flag returnActionFlag - 0 = Return the entire SQLStats-flag value [DEFAULT] 1 = Return only the {action-flag} value, which is the portion of the SQLStats-flag represented by the 1st colon (:) piece NOTE: This is the backward-compatible value ptInfo - A Pass By Reference information array that returns to the user detailed information in the following format: ptInfo(category,variable)=value Where category = { "current" | "terminate" | ["expired"] | ... } variable = A variable that corresponds to the given 'category' Example: ptInfo("current","SQLStatsFlag")=The SQLStats-flag value after method execution RETURN: The current value of the SQLStats-flag; Otherwise, return an error message if an error occurred

    classmethod GetSQLStatsFlagByPID(pid As %String = "", returnActionFlag As %Integer = 0, ByRef ptInfo As %ArrayOfObjects) as %Integer [ Language = objectscript ]

    Method: GetSQLStatsFlagByPID [SQL: StatsSQL_GetSQLStatsFlagByPID] Purpose: This method gets the flag that controls whether or not we collect SQL Statistics about each SQL Query execution for the given 'pid' Get the current value of the SQLStats-flag for the given 'pid'. The SQLStats-flag (Process/Job) controls whether or not SQL Statistics are collected for each SQL Query execution, and which performance statistics to be collected. The SQLStats-flag is a colon (:) delimited string comprised of the following individual components: SQLStats-flag={action-flag}:{collect-flag}:{condition-flag}:{condition-value}:{terminate-flag} NOTE: This method ONLY applies to the SQLStats-flag for the given 'pid' (Process/Job) and NOT the SQLStats-flag for the (System)! RESTRICTION: This method invocation requires %Admin_Operate:Use privilege Invocation: This method can be invoked in the following ways: Object Script: $SYSTEM.SQL.GetSQLStatsFlagByPID(...) ##class(%SYS.PTools.StatsSQL).GetSQLStatsFlagByPID(...) SQL: SELECT %SYS_PTools.StatsSQL_GetSQLStatsFlagByPID(...) Examples: The following examples shows the use of this method: #1 Get the current value of the SQLStats-flag for the Job/System Flag based on SQLStats-flag Rules for PID# 12345: set SQLStatsFlag=##class(%SYS.PTools.StatsSQL).GetSQLStatsFlagByPID(12345) Parameters: pid - The process ID ($JOB) for which to set the SQLStats-flag [DEFAULT: Current $JOB] returnActionFlag - 0 = Return the entire SQLStats-flag value [DEFAULT] 1 = Return only the {action-flag} value, which is the portion of the SQLStats-flag represented by the 1st colon (:) piece NOTE: This is the backward-compatible value ptInfo - A Pass By Reference information array that returns to the user detailed information in the following format: ptInfo(category,variable)=value NOTE: This method currently returns no 'ptInfo', but is included for future extensibility RETURN: The current value of the SQLStats-flag; Otherwise, return an error message if an error occurred

    classmethod GetSQLStatsSaveFlag(flagType As %Integer = "") as %Library.Integer [ Language = objectscript ]
    Gets the flag that controls what type of SQL Statistics to gather about each run of a query

    Get the current value of the SQLStatsSave-flag for the given 'flagType'.

    The SQLStatsSave-flag (System/Job) controls what type of SQL Statistics are saved, either Optimal (new) or Original (backward-compatible).

    The SQLStatsSave-flag is a colon (:) delimited string comprised of the following individual flags: {type-flag} & {method-flag}

    SQLStatsSave-flag={type-flag}:{method-flag}

    RULES: When (flagType=""), whether to use the SQLStatsSave-flag (System) or the SQLStatsSave-flag (Process/Job) is determined by the following rules:
    IF {type-flag} (Process/Job) = 0, then use SQLStatsSave-flag (System)
    ELSE use SQLStatsSave-flag (Process/Job)

    Invocation

    • set SQLStatsSaveFlag=$SYSTEM.SQL.GetSQLStatsSaveFlag(flagType)

    Parameters

    flagType
    • "" = Job/System Flag based on SQLStatsSave-flag Rules [DEFAULT]
    • 0 = System Flag
    • 1 = Process/Job Flag

    Returns:
    The current value of the SQLStatsSave-flag;
    Otherwise, return an error message if an error occurred

    classmethod GetSelectMode() as %Integer [ Language = objectscript ]
    Return the select mode value for the current process. Possible values are:

    0Logical
    1ODBC
    2Display
    The select mode returned by this API is used when:
    #SQLCompile Select = Runtime
    is specified for the compiled SQL code.
    When the SQL statement is compiled in Runtime mode, the mode returned by GetSelectMode will be used at runtime to determine whether Logical(0), ODBC(1), or Display(2) mode is used for the statement. See the documentation for #SQLCompile Select for more information.
    classmethod GetServerDisconnectCode() as %Library.String [ Language = objectscript ]
    Returns ODBC/JDBC disconnect code. Upon disconnect any ObjectScript code defined in this setting will be executed immediately before the server process Halts. This code will also attempt to be executed anytime the server process encounters an unrecoverable error that causes the server process to Halt. It will not be executed if the server process encounters a Halt in other user defined code, if the process crashes, if the process is stopped, or InterSystems IRIS is stopped or forced down. If no disconnect code is defined for this namespace, "" is returned. The disconnect code is defined on a per-namespace basis.

    Examples:

    • Write $SYSTEM.SQL.GetServerDisconnectCode()
    classmethod GetServerInitCode() as %Library.String [ Language = objectscript ]
    Returns ODBC/JDBC/SQL Manager initialization code. This Initialization code is executed at login time when connecting to SQL through ODBC, JDBC, or the SQL Manager. If no initialization code is defined for this namespace, "" is returned. Initialization code is defined on a per-namespace basis.

    Examples:

    • Write $SYSTEM.SQL.GetServerInitCode()
    classmethod GrantObjPriv(ObjPriv As %String, ObjList As %String, Type As %String, User As %String, wGrant As %Integer = 0, ByRef SQLCODE As %Integer) as %Status [ Language = objectscript ]
    GrantObjPriv lets you grant an ObjPriv to a User via this call instead of using the SQL GRANT statement

    $SYSTEM.SQL.GrantObjPriv(ObjPriv,ObjList,Type,User,wGrant)

    Paramaters:

    ObjPriv
    Comma delimited string of actions to grant. * for all actions:
    • Alter
    • Select
    • Insert
    • Update
    • Delete
    • References
    • Execute
    • or any combination
    ObjList
    * for all objects, else a comma delimited list of object names
    Type
    Table, View, Schema or Stored Procedures
    Users
    Comma delimited list of users
    wGrant
    0/1 for WITH GRANT OPTION
    SQLCODE
    By reference parameter that can be used to return an SQLCODE value for the GRANT
    classmethod HOUR(timeexp As %Library.String = "") as %Library.Integer [ Language = objectscript ]
    HOUR is a date/time function that returns an integer from 0 to 23 that corresponds to the hour component in a given date-time expression.

    $SYSTEM.SQL.HOUR(timeexp)

    timeexp
    An expression that is a logical %Library.Time, %Library.TimeStamp, or %Library.PosixTime value.
    classmethod INSTR(string As %Library.String = "", substring As %Library.String = "", position As %Library.Integer = 1, occurrence As %Library.Integer = 1) as %Library.Integer [ Language = objectscript ]
    INSTR is a function that searches string for substring and returns an integer indicating the position of the character in string that is the first character of this occurrence.

    $SYSTEM.SQL.INSTR(string,substring,position,occurrence)

    string
    The string to search in.
    substring
    The string to search for in string.
    position
    A nonzero integer indicating the character of string where InterSystems IRIS begins the search. If position is negative, then InterSystems IRIS counts backward from the end of string and then searches backward from the resulting position.
    occurrence
    An integer indicating which occurrence of substring InterSystems IRIS should search for. If occurrence is greater than 1, then InterSystems IRIS searches for the second occurrence beginning with the second character in the first occurrence of string, and so forth. An occurrence of less than 1 is treated the same as 1.
    classmethod IRIS() as %Library.String [ Language = objectscript ]
    Import an IRIS SQL script file. For InterSystems IRIS SQL script files, the default end-of-statement marker is the string GO. The end-of-statement marker must be on a line by itself after the statement.
    classmethod ImportDir(pDialect As %Library.String = "", pDirectory As %Library.String = "", pLogfile As %Library.String = "", pExtensions As %Library.String = "sql", eosDelimiter As %Library.String = "", pRecurse As %Integer = 0, pMessageMode As %Boolean = 1, pEchoMode As %Boolean = 1, pErrorPause As %Integer = 5) [ Language = objectscript ]
    Import all DDL/DML script files in a given directory. All files with the extension .sql in the directory will be imported. The caller can optionally specify a comma delimited list of file extensions to import. Subdirectories are also recursively processed if the caller specifies the pRecurse argument as 1.

    Parameters:
    pDialect
    Vendor from which the script file originated. This parameter is required. Supported values are:
    • MSSQL
    • MSSQLServer - same as MSSQL
    • Sybase
    pDirectory
    The full path name of the directory to import. This parameter is required.
    pLogfile
    The full path name of the file to report errors in. This parameter is Optional. Default is SQLImportDir.log in the directory loaded. If this parameter value is 1, a separate log file will be generated for each file loaded. The name of the log file will be the same as the file imported, but with the extension .log instead of .sql.
    pExtensions
    A comma delimited list of file extensions to import. This parameter is optional and defaults to "sql".
    eosDelimiter
    End of statement delimiter. Will default to an appropriate value based on the value of %DDLMode. This parameter is optional.
    pRecurse
    If pRecurse is 1 then subdirectories of pDirectory will be recursively imported. This parameter is optional and defaults to 0.
    pMessageMode
    If true then all messages reported by executing imported statements will be displayed on the current device.
    pEchoMode
    If true, all statement source is displayed on the current device.
    pErrorPause
    The number of seconds to pause when an error is reported. The default is five seconds.

    Examples:

    • Do $SYSTEM.SQL.ImportDir("Sybase","C:\Work\db1\","C:\Work\db1\import.log","sql",";")
    • Do $SYSTEM.SQL.ImportDir("Sybase","C:\Work\db1\","C:\Work\db1\import.log","sql,tab,sp",";",1)
    • Do $SYSTEM.SQL.ImportDir("Sybase","C:\Work\db1\",,,";")
    classmethod ImportSQLStatement(Filename As %Library.String = "", Display As %Library.Boolean = 1) as %Library.Status [ Language = objectscript ]
    Import a file containing SQL Statement Index entries. Files can be loaded that were generated with $SYSTEM.SQL.ExportStatement() or $SYSTEM.SQL.ExportAllStatements().
    The main reason to export/import an SQL Statement entry is to move a frozen plan from one location to another. Other than moving a frozen plan, there is not much benefit of moving an SQL Statement definition from one location to another. When exporting SQL Statement definitions, the Locations (routines) the SQL Statement is defined in is not exported. This is because it is possible the Locations are different or don't exist on the target system. Recompiling the class/routines that contain the SQL Statement on the target system will redeine the Location entries for the SQL Statement definition.

    Parameter:
    Filename
    Name of the file to output the SQL Statement definition to.
    Display
    1/0 Flag. If 1, display import progress on the screen. Default is 1.

    Examples:

    • Do $SYSTEM.SQL.ImportSQLStatement("C:\MyStatements.xml",1) // Imports SQL Statement(s) defined in the file
    classmethod ImportTuneStats(pFilename As %Library.String, pDisplay As %Library.Boolean = 1, pKeepClassUpToDate As %Library.Boolean = 0, pClearCurrentStats As %Library.Boolean = 0) as %Library.Status [ Language = objectscript ]
    Import extentsize, selectivity, blockcount for a table and its fields from a file created by $SYSTEM.SQL.ExportTuneStats().

    Parameter:
    pFilename
    Name of the file to output the table(s) tuning statistics to.
    pDisplay
    TRUE(1)/FALSE(0) flag. Displays progress messages to the current device if TRUE. The default is TRUE (1).
    pKeepClassUpToDate
    TRUE(1)/FALSE(0) flag. If TRUE (and update is TRUE), the class definition will be updated with the new EXTENTSIZE and SELECTIVITY values, but the class definition will be kept as up-to-date. In many cases, however, it is desirable to recompile the class after its table has been tuned so that queries in the class definition can be recompiled and the SQL query optimizer can use the updated data statistics. The default is FALSE (0). Note that if the class is deployed the class definition will not be updated.
    pClearCurrentStats
    TRUE(1)/FALSE(0) flag. If TRUE(1), any EXTENTSIZE, SELECTIVITY, BLOCKCOUNT, etc. will be cleared from the existing table prior to importing the stats. This can be used if you want to completely clear stats that are not specified in the import file instead of leaving them defined in class/table. The default is FALSE (0)

    Examples:

    • Do $SYSTEM.SQL.ImportTuneStats("C:\AllStats.xml") // Import TuneTable Statistics for all schemas/tables that were exported with the $SYSTEM.SQL.ExportTuneStats() to the AllStats.xml file
    classmethod Informix() as %Library.String [ Language = objectscript ]
    Import an Informix DDL/DML script file.
    The Informix DDL/DML Import Utility supports the following statements:
    • CREATE TABLE ...
    • ALTER TABLE ...
    • CREATE INDEX ...
    • CREATE VIEW ...
    • SET OPTION ...
    • GRANT { ALTER | SELECT | INSERT | UPDATE | DELETE | REFERENCES | ALL PRIVILEGES } ...
    Statements other than the ones above are not handled by the utility and must be added to your application manually (if applicable).
    classmethod InterBase() as %Library.String [ Language = objectscript ]
    Import an Interbase DDL/DML script file.
    The Interbase DDL/DML Import Utility supports the following statements:
    • CREATE TABLE ...
    • ALTER TABLE ...
    • CREATE INDEX ...
    • CREATE UNIQUE INDEX ...
    • CREATE VIEW ...
    • CREATE ROLE ...
    Statements other than the ones above are not handled by the utility and must be added to your application manually (if applicable).
    classmethod IsReservedWord(word As %Library.String) as %Library.Boolean [ Language = objectscript, SQLProc = SQL_IsReservedWord ]
    This entry point can be used to determine if a string is an SQL Reserved word.

    Parameters:
    word
    The word to check against the SQL Reserved Word list.

    Examples:

    • Write $SYSTEM.SQL.IsReservedWord("select") // Writes a 1
    • Write $SYSTEM.SQL.IsReservedWord("football") // Writes a 0
    This method can also be called as a Stored Procedure named %SYSTEM.SQL_IsReservedWord(word)
    classmethod IsValidRegularIdentifier(identifier As %Library.String) as %Library.Boolean [ Language = objectscript, SQLProc = SQL_IsValidRegularIdentifier ]
    This entry point can be used to determine if an SQL identifier is a valid regular SQL identifier. An SQL regular identifier must begin with '%', '_', or a letter followed by 0 or more letters, numbers, '_', '@', '#', or '$' characters. It must also not be an SQL Reserved word. Identifiers which do not qualify as Regular identifiers must be specified as Delimited identifiers in SQL statements.

    Parameters:
    identifier
    Name of the identifier to check.

    Examples:

    • Write $SYSTEM.SQL.IsValidRegularIdentifier("select") // Writes a 0 (reserved word)
    • Write $SYSTEM.SQL.IsValidRegularIdentifier("football") // Writes a 1
    • Write $SYSTEM.SQL.IsValidRegularIdentifier("%Correct") // Writes a 1
    • Write $SYSTEM.SQL.IsValidRegularIdentifier("%Correct_$Amount") // Writes a 1
    This method can also be called as a Stored Procedure named %SYSTEM.SQL_IsValidRegularIdentifier(identifier)
    classmethod LASTDAY(dateexp As %Library.String = "") as %Library.Date [ Language = objectscript ]
    LASTDAY is a scalar date/time function that returns the %Library.Date value of the last day of the month for a given date expression.

    $SYSTEM.SQL.LASTDAY(dateexp)

    dateexp
    A %Library.Date, %Library.TimeStamp, or %Library.Posix logical value.
    LASTDAY returns the date of the last day of the specified month as a %Library.Date value. Leap years differences are calculated.

    LASTDAY returns 0 when an invalid date is specified: the day or month as zero; the month greater than 12; or the day larger than the number of days in that month on that year.

    classmethod MINUTE(timeexp As %Library.String = "") as %Library.Integer [ Language = objectscript ]
    MINUTE is a date/time function that returns an integer from 0 to 59 that corresponds to the minute component in a given date-time expression.

    $SYSTEM.SQL.MINUTE(timeexp)

    timeexp
    An expression that is a logical %Library.Time, %Library.TimeStamp, or %Library.PosixTime value.
    classmethod MONTH(dateexp As %Library.String = "") as %Library.Integer [ Language = objectscript ]
    MONTH is a date/time function that returns an integer from 1 to 12 that corresponds to the month in a given date expression.

    $SYSTEM.SQL.MONTH(dateexp)

    dateexp
    An expression that is a logical %Library.Date, %Library.TimeStamp, or %Library.PosixTime value.
    classmethod MONTHNAME(dateexp As %Library.String = "") as %Library.String [ Language = objectscript ]
    MONTHNAME is a date/time function that returns a character string containing the name of the month in a given date expression.

    $SYSTEM.SQL.MONTHNAME(dateexp)

    dateexp
    An expression that is a logical %Library.Date, %Library.TimeStamp, or %Library.PosixTime value.
    classmethod MSSQLServer() as %Library.String [ Language = objectscript ]
    Import an MS SQL Server DDL/DML script file.
    The MS SQL Server DDL/DML Import Utility supports the following statements:
    • CREATE [GLOBAL TEMPORARY] TABLE ...
    • CREATE VIEW ...
    • ALTER TABLE ...
    • CREATE INDEX ...
    • CREATE CLUSTERED INDEX ...
    • CREATE UNIQUE INDEX ...
    • INSERT ...
    • UPDATE ...
    • DELETE ...
    • SET OPTION ...
    Statements other than the ones above are not handled by the utility and must be added to your application manually (if applicable).
    classmethod MVR(stringexp As %Library.String = "") as %Library.String [ Language = objectscript ]
    MVR returns the MVR collation of the passed in value.

    $SYSTEM.SQL.MVR(stringexp)

    stringexp
    Any string expression value.
    MVR performs collation translations needed for MultiValue
    classmethod Oracle() as %Library.String [ Language = objectscript ]
    Import an Oracle DDL/DML script file.
    The Oracle DDL/DML Import Utility supports the following statements:
    • CREATE TABLE ...
    • CREATE VIEW ...
    • ALTER TABLE ...
    • CREATE INDEX ...
    • CREATE UNIQUE INDEX ...
    • DROP TABLE ...
    • DROP VIEW ...
    • DROP INDEX ...
    • INSERT ...
    • UPDATE ...
    • DELETE ...
    • SET OPTION ...
    • CREATE USER ...
    • CREATE ROLE ...
    • GRANT { SELECT | INSERT | UPDATE | DELETE | REFERENCES | ALL PRIVILEGES } ...
    Statements other than the ones above are not handled by the utility and must be added to your application manually (if applicable).
    classmethod Prepare(ByRef SQL As %String(MAXLEN=""), SelectMode As %String = {$zu(115, 5)}, Dialect As %String = "", ObjectSelectMode As %Integer = 0) as %SQL.Statement [ Language = objectscript ]

    Prepare an SQL query and return the prepared statement object.

    This function returns a statement oref if the query is successfully prepared. If the query cannot be successfully prepared then an exception is thrown.

    A prepared statement can be executed by calling %Execute(). %Execute() accepts arguments that align with parameters present as question marks in the prepared query. Literals in the prepared query are managed automatically.

    A prepared statement may also be reused for a different query by simply invoking %Prepare() on the statement, passing in a new query. Refer to the %Prepare method in %SQL.Statement for more information.


    Parameters:
    SQL
    SQL statement to prepare. This can be an array of SQL statement lines with the base node set to the number of lines or it can be a single string..
    SelectMode
    The statement SELECTMODE - LOGICAL, ODBC or DISPLAY.
    Can also be specified as 0, 1, or 2.
    Dialect
    The SQL dialect used for this SQL statement. Valid values are IRIS, MSSQLSERVER, MSSQL, and SYBASE. The default is IRIS. Support for MSSQLSERVER and SYBASE dialects is limited to a subset of the TSQL grammar supported by the InterSystems IRIS TSQL language mode.
    ObjectSelectMode
    The statement %ObjectSelectMode value - 0 or 1. Refer to %SQL.Statement for more information on ObjectSelectMode.

    Examples:

    • set statement = $SYSTEM.SQL.Prepare("select top ? name,dob,ssn from sample.person order by name")
    • set statement = $SYSTEM.SQL.Prepare("select top 5 name,dob,ssn,home_street,,home_city + ', ' + home_state + ' ' + home_zip from sample.person order by name",1,"MSSQL")
    • set sql=2,sql(1)="select top 5 name,dob,ssn from sample.person"
      set sql(2)=" order by name"
      set statement = $SYSTEM.SQL.Prepare(.sql)
    • set statement = $SYSTEM.SQL.Prepare("insert into sample.person (name,dob,ssn) values (?,?,?)",2)
    classmethod ProcedureExists(procname As %Library.String = "", ByRef metadata As %String) as %Library.Boolean [ Language = objectscript, SQLProc = SQL_ProcedureExists ]
    This entry point can be used to determine if a stored procedure exists.

    Parameters:
    procname
    Name of the stored procedure to check.
    procname can be qualified or unqualified. If unqualified, the default schema is applied.
    metadata
    Passed by reference, optional argument.
    If the stored procedure exists, returns the following information about the procedure: $ListBuild(SchemaName,ProcedureName,Classname that projected the stored procedure,procedure type)

    Examples:

    • Write $SYSTEM.SQL.ProcedureExists("SQLUser.stpSalaryReport") // Writes a 1 if procedure SQLUser.stpSalaryReport exists
    • Write $SYSTEM.SQL.ProcedureExists("stpSalaryReport",.metadata) // Writes a 1 if procedure [DefaultSchema].stpSalaryReport exists, returns metadata=$lb("SQLUser","stpSalaryReport","User.stpSalaryReport","function")

    Notes:

    • If the user calling the function does not hold any privileges for the procedure, 0 will be returned.
    • If a class exists that would project this procedure to SQL during compilation, but the class has not been compiled, 0 will be returned.
    • If a procedure is marked as hidden, 0 will be returned.
    • metadata will be set to "" if 0 is returned by the function.
    This method can also be called as a Stored Procedure named %SYSTEM.SQL_ProcedureExists(procname)
    classmethod Purge(days As %Library.Integer = 0) as %Library.String [ Language = objectscript ]
    Purges Cached Queries.

    Parameter:
    days
    Number of days. Purge cached queries not prepared in more than days days.

    Examples:

    • Do $SYSTEM.SQL.Purge(0) // Purge all Cached Queries
    • Do $SYSTEM.SQL.Purge() // Purge all Cached Queries
    • Do $SYSTEM.SQL.Purge(30) // Purge all Cached Queries that have not be used (prepared) in the last 30 days
    classmethod PurgeAllNamespaces() as %Library.String [ Language = objectscript ]
    Purges Cached Queries in all namespaces on this system

    Example:

    • Do $SYSTEM.SQL.PurgeAllNamespaces() // Purge all Cached Queries on this system
    classmethod PurgeCQClass(Classlist As %Library.String) as %Library.String [ Language = objectscript ]
    Purges Cached Queries given the name(s) of the Cached Query Classes.

    Parameter:
    Classlist
    The name of the cached query class to purge, or a comma delimited list of cached query class names to purge.

    Examples:

    • Do $SYSTEM.SQL.PurgeCQClass("%sqlcq.USER.cls13") ; Purge this Cached Query
    • Do $SYSTEM.SQL.PurgeCQClass("%sqlcq.USER.cls13,%sqlcq.USER.cls16,%sqlcq.USER.cls124") ; Purge these 3 Cached Queries
    classmethod PurgeForRoutine(routine As %Library.String) as %Library.String [ Language = objectscript ]
    Purges Cached Queries given the name(s) of the Cached Query Classes.
    This entry point is deprecated. $SYSTEM.SQL.PurgeCQClass(classname) should be used instead.

    Parameter:
    routine
    The name of the cached query class to purge, or a comma delimited list of cached query class names to purge.

    Examples:

    • Do $SYSTEM.SQL.PurgeForRoutine("%sqlcq.USER.cls13") ; Purge this Cached Query
    • Do $SYSTEM.SQL.PurgeForRoutine("%sqlcq.USER.cls13,%sqlcq.USER.cls16,%sqlcq.USER.cls124") ; Purge these 3 Cached Queries
    classmethod PurgeForTable(table As %Library.String) as %Library.String [ Language = objectscript ]
    Purges all Cached Queries which use table table.

    Parameter:
    table
    The qualified name of the table to purge the Cached Queries for. If the schema is not specified, the default schema will be used.

    Examples:

    • Do $SYSTEM.SQL.PurgeForTable("MedLab.Patient")
    • Do $SYSTEM.SQL.PurgeForTable("IscPerson") ; Purges Cached Queries for SQLUser.IscPerson
    classmethod QUARTER(dateexp As %Library.String = "") as %Library.Integer [ Language = objectscript ]
    QUARTER is a date/time function that returns an integer from 1 to 4 that corresponds to the quarter of the year in a given date expression.

    $SYSTEM.SQL.QUARTER(dateexp)

    dateexp
    An expression that is a logical %Library.Date, %Library.TimeStamp, or %Library.PosixTime value.
    classmethod QueryToTable(ByRef query As %Library.String, table As %Library.String, display As %Library.Boolean = 0, ByRef error As %Library.String) as %Library.String [ Language = objectscript ]
    Turn the results of a query into a table definition. This utility takes a query and the name of a new table and executes the query. The results of the query are turned into a new table of name 'table'.

    Parameters:
    query
    The query text to execute. query can be of the format:
    query="sql text"
    OR
    query = # of lines
    query(1) = sql line 1
    query(n) = sql line n
    
    table
    Name of the new SQL table to generate. The name may be qualified with a schema name: Medical.Patient If the schema name is omitted, the default schema is used.
    display
    TRUE(1)/FALSE(0) flag. Displays progress messages to the current device if TRUE. The default is FALSE (0).
    error
    Array of error messages returned if there is a problem. The format is:
    error = # of error lines
    error(1) = error line 1
    error(n) = error line n
    

    Examples:

    Do $SYSTEM.SQL.QueryToTable("SELECT * FROM MedLab.Patient WHERE Sex = 'Male'","MedLab.MalePatient",1,.errors)
    Set query=3
    Set query(1)="SELECT *"
    Set query(2)=" FROM ""Med Lab"".Patient""
    Set query(3)=" WHERE Sex = 'Male'"
    Do $SYSTEM.SQL.QueryToTable(.query,"""Med Lab"".MalePatient",1,.errors)
    Do $SYSTEM.SQL.QueryToTable("SELECT * FROM Patient WHERE Sex = 'Male'","MalePatient",1,.errors) ; Creates SQLUser.MalePatient
    
    classmethod RevokeObjPriv(ObjPriv As %String, ObjList As %String, Type As %String, User As %String, wGrant As %Integer = 0, Cascade As %Integer = 0, AsGrantor As %String = "", ByRef SQLCODE As %Integer) as %Status [ Language = objectscript ]
    RevokeObjPriv lets you revoke an ObjPriv from a User via this call instead of using the SQL REVOKE statement

    $SYSTEM.SQL.RevokeObjPriv(ObjPriv,ObjList,Type,User,wGrant,Cascade,AsGrantor)

    Paramaters:

    ObjPriv
    Comma delimited string of actions to grant. * for all actions:
    • Alter
    • Select
    • Insert
    • Update
    • Delete
    • References
    • Execute
    • or any combination
    ObjList
    * for all objects, else a comma delimited list of object names
    Type
    Table, View, Schema or Stored Procedures
    Users
    Comma delimited list of users
    wGrant
    0/1 for WITH GRANT OPTION
    Cascade
    0/1 cascade revoke?
    AsGrantor
    Alternate User to remove Privs for. As Grantor can be a user name, a comma-separated list of user names, or "*".
    SQLCODE
    By reference parameter that can be used to return an SQLCODE value for the GRANT
    classmethod RoleExists(rolename As %Library.String = "") as %Library.Boolean [ Language = objectscript, SQLProc = SQL_RoleExists ]
    This entry point can be used to determine if a role exists.

    Parameters:
    rolename
    Name of the role to check.

    Examples:

    • Write $SYSTEM.SQL.RoleExists("SalesManager") // Writes a 1 if role SalesManager exists
    This method can also be called as a Stored Procedure named %SYSTEM.SQL_RoleExists(rolename)
    classmethod SECOND(timeexp As %Library.String = "") as %Library.Integer [ Language = objectscript ]
    SECOND is a date/time function that returns an integer from 0 to 59 that corresponds to the second component in a given date-time expression.

    $SYSTEM.SQL.SECOND(timeexp)

    timeexp
    An expression that is a logical %Library.Time, %Library.TimeStamp, or %Library.PosixTime value.
    classmethod SQLCODE(SQLCODE As %Library.Integer) as %Library.String [ Language = objectscript, SQLProc = SQL_SQLCODE ]
    This entry point can be used to return the description of an SQLCODE value.

    Parameters:
    SQLCODE
    SQLCODE value.

    Examples:

    • Write $SYSTEM.SQL.SQLCODE(-105)
    • Write $SYSTEM.SQL.SQLCODE(100)
    This method can also be called as a Stored Procedure named %SYSTEM.SQL_SQLCODE(SQLCODE)
    classmethod SQLSTRING(stringexp As %Library.String = "", maxlen As %Library.Integer) as %Library.String [ Language = objectscript ]
    SQLSTRING returns the SqlString collation of the passed in value.

    $SYSTEM.SQL.SQLSTRING(stringexp,maxlen)

    stringexp
    Any string expression value.
    maxlen
    Optional. An integer, which specifies that the collated value will be truncated to the value of maxlen.
    SQLSTRING converts stringexp to a format that is sorted as a (case-sensitive) string. SQLSTRING strips trailing white space (spaces, tabs, and so on) from the string, then adds one leading blank space to the beginning of the string. It collates any value containing only white space (spaces, tabs, and so on) as the SQL empty string. SQL Empty string is represented as $Char(0) in ObjectScript, which collated as SqlString is " "_$Char(0).
    classmethod SQLUPPER(stringexp As %Library.String = "", maxlen As %Library.Integer) as %Library.String [ Language = objectscript ]
    SQLUPPER returns the SqlUpper collation of the passed in value.

    $SYSTEM.SQL.SQLUPPER(stringexp,maxlen)

    stringexp
    Any string expression value.
    maxlen
    Optional. An integer, which specifies that the collated value will be truncated to the value of maxlen.
    SQLUPPER converts stringexp to a format that is sorted as a (case-insensitive) upper-case string. SQLUPPER converts all alphabetic characters to uppercase, strips trailing white space (spaces, tabs, and so on) from the string, then adds one leading blank space to the beginning of the string. It collates any value containing only white space (spaces, tabs, and so on) as the SQL empty string. SQL Empty string is represented as $Char(0) in ObjectScript, which collated as SqlUpper is " "_$Char(0).
    classmethod STRING(stringexp As %Library.String = "", maxlen As %Library.Integer) as %Library.String [ Language = objectscript ]
    STRING returns the String collation of the passed in value.

    $SYSTEM.SQL.STRING(stringexp,maxlen)

    stringexp
    Any string expression value.
    maxlen
    Optional. An integer, which specifies that the collated value will be truncated to the value of maxlen.
    STRING converts stringexp to a STRING collation format.
    STRING converts all alphabetic characters are uppercased; all punctuation characters are removed, except the comma; a single space is added to the beginning of the expression. It collates any value containing only white space (spaces, tabs, and so on) as the SQL empty string. SQL Empty string is represented as $Char(0) in ObjectScript, which collated as String is " "_$Char(0).
    classmethod SetANSIPrecedence(flag As %Library.Boolean = 1, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Set the configuration setting which determines if ANSI operator precedence is applied. The default is use of ANSI precedence is appied.

    Parameter:
    flag
    TRUE(1)/FALSE(0) If flag is FALSE(0), do not apply ANSI precedence in SQL statements. If TRUE(1) (the default), do apply ANSI precedence in SQL.
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetAllowExtrinsicFunctions(flag As %Library.Boolean = 1, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Set the configuration setting which determines if extrinsic functions are allowed to be used in SQL statements through ODBC, JDBC, and Dynamic SQL. The default is use of extrinsic functions is not supported.

    Parameter:
    flag
    TRUE(1)/FALSE(0) If flag is FALSE(0) (the default), do not allow extrinsic functions in SQL statements through ODBC, JDBC, or Dynamic SQL. If TRUE(1), do allow extrinsic functions in SQL statements through ODBC, JDBC, or Dynamic SQL
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetAutoCommit(flag As %Library.Integer = 0) as %Library.Integer [ Language = objectscript ]
    Sets the AUTO_COMMIT mode for this process. Setting takes effect immediately and lasts for the duration of the process or until SetAutoCommit is called again.

    Parameter:
    flag
    0 - No AutoCommit
    1 - AutoCommit ON
    2 - AutoCommit OFF
    Returns:
    Old value (0, 1, or 2) of the AutoCommit setting.
    classmethod SetAutoParallel(flag As %Library.Boolean = 1, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Set the configuration setting which determines if auto hinting %PARALLEL is applied. The default is use of auto hinting %PARALLEL is not appied.

    Parameter:
    flag
    TRUE(1)/FALSE(0) If flag is FALSE(0) (the default), do not apply auto hinting for %PARALLEL in SQL statements. If TRUE(1), do apply auto hinting for %PARALLEL in SQL.
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetAutoParallelThreshold(threshold As %Integer = 10000, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Set the configuration setting which determines the threshold of auto hinting %PARALLEL. Once auto hinting for %PARALLEL is enabled, we could use this function to setup the threshold for this feature. Increasing the threshold means it would lower the chance for the auto hinting for %PARALLEL to happen The default value is 10000. This value could be roughlt thinked of as how many rows in the visited map

    Parameter:
    threshold
    Integer.
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetBitmapFriendlyCheck(pFlag As %Library.Integer = 0, ByRef pOldVal As %Library.Integer) as %Library.Status [ Language = objectscript ]
    Sets the flag to determine if the compiler should check if the bitmap index is allowed in a %Storage.SQL class.
    This setting only applies to classes using %Storage.SQL. If this setting is TRUE (1), during class compilation the compiler will check to make sure the ID of the table is an INTEGER type if there are any bitmap or bitmap extent indices defined. An INTEGER type means the class must have either no IdKey index, or a single field IdKey index. If the class has a single field IdKey index, the type of the IdKey property must be of SqlCategory="INTEGER" or SqlCategory="NUMERIC" with a SCALE=0 and MINVAL=1 or higher. If BitmapFriendlyCheck is set to 1, and the class compile finds a non bitmap friendly class, the class compilation will fail with an error. If BitmapFriendlyCheck=0 and a %Storage.SQL class is defined with an ID that is not a positive integer, it is up to the developer of the class to make sure the index is data is properly stored and retrieved from the global.

    Parameter:
    pFlag
    1 means the class compiler will check to make sure the type of ID of the class is a positive integer if there is a bitmap index defined for the class and the class uses %Storage.SQL.
    0 (the default), means the class compiler will not perform this check and no error will be returned if the class contains a bitmap index and does not have a positive integer ID type.
    pOldVal
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - Changing this configuration setting will only take effect immediately for all processes.
    - This is a system-wide setting.
    classmethod SetCachedQueryLockTimeout(timeout As %Library.Integer = 120, ByRef oldval As %Library.Integer) as %Library.Status [ Language = objectscript ]
    Defines the lock timeout length used for Cached Queries when a lock needs to be acquired on Cached Query metadata. The default is 120 seconds.

    Parameter:
    timeout
    Number of seconds the lock command should timeout after when attempting to lock cached query definitions.
    oldval
    Passed By Reference. Contains the previous value of the setting.

    Returns:

    Status Code

    Examples:

    • Set sc=$SYSTEM.SQL.SetCachedQueryLockTimeout(60) // Sets cached query lock timeout to 60 seconds
    • Set sc=$SYSTEM.SQL.SetCachedQuerySaveSource(300,.oldval) // Sets lock timeout to 5 minutes, returns previous lock timeout setting in oldval.
    NOTES:
    - The setting is on a per system basis.
    classmethod SetCachedQuerySaveSource(flag As %Library.Boolean = 0, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Defines whether or not the source code for cached queries is retained. The default is no source is saved. The setting is on a per-system basis.

    Parameter:
    flag
    TRUE(1)/FALSE(0) flag to set the flag to retain source code for all cached queries. If TRUE (1), source is retained. If FALSE (0), source is deleted after the cached query has compiled.
    oldval
    Passed By Reference. Contains the previous value of the setting.

    Returns:

    Status Code

    Examples:

    • Set sc=$SYSTEM.SQL.SetCachedQuerySaveSource(1) // Retain source
    • Set sc=$SYSTEM.SQL.SetCachedQuerySaveSource(0,.oldval) // Do not retain source
    NOTES:
    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will take effect immediately for all processes in InterSystems IRIS after this function is called. Any new cached queries created by any process will immediately begin saving (or not saving) cached query source. Any existing cached queries will only have source saved if the system was configured to save source at the time the statement was prepared.
    - This is a system-wide setting.
    classmethod SetCollectionProjection(value As %Library.Integer = 0) as %Library.Integer [ Language = objectscript ]
    Sets the collection projection option. Setting takes effect when classes are recompiled.

    Parameter:
    value
    0 - do not project collections as a column if the collection is projected as a child table.
    1 - project all collections as columns.
    Returns:
    Old value (0, 1) of the CollectionProjection setting.
    classmethod SetCompileModeDeferred() as %Library.String [ Language = objectscript ]
    Set the namespace wide flag which turns on Deferred Compilation mode. 'Deferred Compilation Mode' can be used to improve the performance of 'installation-type' activities. Deferred Compilation Mode will, in most cases, reduce the number of class compilations which take place during the loading of tables through DDL scripts. When Deferred Compilation Mode is on, classes are not immediately compiled, but put in a compilation queue which will be compiled at a later time when needed. This is very useful during loading of DDL scripts of the following format:

    - CREATE TABLE MyTable ...
    - CREATE INDEX MyIndex1 ON MyTable ...
    - CREATE INDEX MyIndex2 ON MyTable ...
    - CREATE INDEX MyIndex3 ON MyTable ...
    - CREATE INDEX MyIndex4 ON MyTable ...
    - CREATE INDEX MyIndex5 ON MyTable ...
    - CREATE TABLE MyOtherTable ...
    - CREATE INDEX MyOtherIndex1 ON MyOtherTable ...
    - CREATE INDEX MyOtherIndex2 ON MyOtherTable ...
    - CREATE INDEX MyOtherIndex3 ON MyOtherTable ...
    - CREATE INDEX MyOtherIndex4 ON MyOtherTable ...
    - CREATE INDEX MyOtherIndex5 ON MyOtherTable ...
    - ALTER TABLE MyOtherTable ADD FOREIGN KEY MyFKey (MyField) REFERENCES MyTable(MyField)
    - INSERT INTO MyTable ...

    Running with Deferred Compilation Mode off would require 13 class compilations for the sequence above. With Deferred Compilation Mode on, only two class compilations are required. Classes MyTable and MyOtherTable are compiled when the INSERT statement is encountered.
    There are two ways to turn Deferred Compilation Mode on:

    - Execute the following SQL statement:
        SET OPTION COMPILEMODE = DEFERRED
    - Call the API entry point:
        Do $SYSTEM.SQL.SetCompileModeDeferred()

    If Deferred Compilation Mode is already turned on, no error will be returned.

    To return to Immediate Compilation Mode:

    - Execute the following SQL statement:
        SET OPTION COMPILEMODE = IMMEDIATE
    - Call the API entry point:
        Do $SYSTEM.SQL.SetCompileModeImmediate()

    Changing from Deferred to Immediate Compilation Mode will cause any classes in the Deferred Compile Queue to be compiled immediately. If all class compilations were successful, SQLCODE will return 0. If there were any errors, SQLCODE will equal -400. Class compilation errors are logged in the ^mtemp2($namespace,"Deferred Compile Mode","Error"). If SQLCODE=-400 you should view this global structure for more precise error messages.

    When in Deferred Compilation Mode, any of the following actions will trigger the classes in the Deferred Compilation Queue to be immediately compiled:
    • Switch back to immediate compile mode.
    • An xDBC Catalog query is called.
    • A DML statement is issued (INSERT, SELECT, GRANT, etc)
    • CREATE INDEX statement is executed.
    • DROP INDEX statement is executed.
    • ALTER TABLE to add a required field to a table with a default value.
    • ALTER TABLE to modify a field to be required.

    Deferred Compilation Mode should only be used in an installation-type setting where only a single process is working on the namespace at the time.

    Returns:

    "" (null) string

    NOTES:
    - Changing this setting will take effect immediatly for all processes in this namespace.
    - This setting is not related to the macro compiler directive #SQLCompile Mode = { deferred | embedded | immediate }
    classmethod SetCompileModeImmediate() as %Library.String [ Language = objectscript ]
    Set the namespace wide flag which turns on Immediate Compilation mode. Immediate Compile Mode is the default compilation mode. If there are pending compilations when switching from Deferred/Install Compile Mode, they will be compiled immediately. See CompileModeDeferred(), CompileModeInstall(), and CompileModeNocheck() for more information.

    Returns:

    "" (null) string

    NOTES:
    - Changing this setting will take effect immediatly for all processes in this namespace.
    - This setting is not related to the macro compiler directive #SQLCompile Mode = { deferred | embedded | immediate }
    classmethod SetCompileModeInstall() as %Library.String [ Language = objectscript ]
    Set the namespace wide flag which turns on Install Compilation mode. This mode should only be used for installation procedures where no data exists for any of the tables being created. If data exists for the tables definitions being manipulated through DDL statement, use Deferred Compile Mode instead. This is very useful during loading of DDL scripts of the following format:

    - CREATE TABLE MyTable ...
    - CREATE INDEX MyIndex1 ON MyTable ...
    - CREATE INDEX MyIndex2 ON MyTable ...
    - CREATE INDEX MyIndex3 ON MyTable ...
    - CREATE INDEX MyIndex4 ON MyTable ...
    - CREATE INDEX MyIndex5 ON MyTable ...
    - CREATE TABLE MyOtherTable ...
    - CREATE INDEX MyOtherIndex1 ON MyOtherTable ...
    - CREATE INDEX MyOtherIndex2 ON MyOtherTable ...
    - CREATE INDEX MyOtherIndex3 ON MyOtherTable ...
    - CREATE INDEX MyOtherIndex4 ON MyOtherTable ...
    - CREATE INDEX MyOtherIndex5 ON MyOtherTable ...
    - ALTER TABLE MyOtherTable ADD FOREIGN KEY MyFKey (MyField) REFERENCES MyTable(MyField)
    - INSERT INTO MyTable ...

    Running with Install Compilation Mode off would require 13 class compilations for the sequence above. With Install Compilation Mode on, only one class compilation is required. Classes MyTable and MyOtherTable are compiled when the INSERT statement is encountered.
    There are two ways to turn Install Compilation Mode on:

    - Execute the following SQL statement:
        SET OPTION COMPILEMODE = INSTALL
    - Call the API entry point:
        Do $SYSTEM.SQL.SetCompileModeInstall()

    If Install Compilation Mode is already turned on, no error will be returned.

    To return to Immediate Compilation Mode:

    - Execute the following SQL statement:
        SET OPTION COMPILEMODE = IMMEDIATE
    - Call the API entry point:
        Do $SYSTEM.SQL.SetCompileModeImmediate()

    Changing from Install to Immediate Compilation Mode will cause any classes in the Deferred Compile Queue to be compiled immediately. If all class compilations were successful, SQLCODE will return 0. If there were any errors, SQLCODE will equal -400. Class compilation errors are logged in the ^mtemp2($namespace,"Deferred Compile Mode","Error"). If SQLCODE=-400 you should view this global structure for more precise error messages.

    When in Install Compilation Mode, any of the following actions will trigger the classes in the Deferred Compilation Queue to be immediately compiled:
    • Switch back to immediate compile mode.
    • An xDBC Catalog query is called.
    • A DML statement is issued (INSERT, SELECT, GRANT, etc)

    Install Compilation Mode should only be used in an installation-type setting where only a single process is working on the namespace at the time and there is no data in the tables.

    Returns:

    "" (null) string

    NOTES:
    - Changing this setting will take effect immediatly for all processes in this namespace.
    - This setting is not related to the macro compiler directive #SQLCompile Mode = { deferred | embedded | immediate }
    classmethod SetCompileModeNocheck() as %Library.String [ Language = objectscript ]
    Set the namespace wide flag which turns on Nocheck Compilation mode. This mode is the same as immediate mode except that existing data is not validated against new constraints. For example if you add a unique constraint to a table that already has data, Nocheck mode will not validate that the constraint is valid. This compile mode must be used with extreme caution. You could end up with data integrity problems in your application.

    In NOCHECK compile mode, the following constraints are not checked when executing DDL statements:
    • If a table is dropped, there are no checks to see if any foreign key constraints in other tables reference this table.
    • If a foreign key constraint is added, there are no checks to see if any existing data in the table is valid for the foreign key.
    • If a NOT NULL constraint is added to a table with existing data, there is no validation that any existing rows are NOT NULL, nor is there an update existing rows to assign the field's default value if there is one.
    • If a UNIQUE or Primary key constraint is deleted, there is no check to see if a foreign key in this or another table had referenced the key.
    Otherwise, the mode behaves the same as immediate. There is no deferring of class compilations and indices are built when created. Changing this setting will only take effect for this process.

    Returns:

    "" (null) string

    NOTES:
    - Changing this setting will take effect immediatly for all processes in this namespace.
    - This setting is not related to the macro compiler directive #SQLCompile Mode = { deferred | embedded | immediate }
    classmethod SetDDLDefineBitmapExtent(flag As %Library.Boolean = 1, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the flag which determines if a class created by a DDL CREATE TABLE statement defines a bitmap extent index for the class. This setting only applies to classes created through DDL that do not also define an explicit IdKey index.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide flag to define a bitmap extent index for classes created by CREATE TABLE. Otherwise, do not define the bitmap extent index for the class.
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    - The default setting is TRUE, the class will define a bitmap extent index.
    classmethod SetDDLDropTabDelData(flag As %Library.Boolean = 1, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the flag which determines if a DDL DROP TABLE statement deletes the table's data.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide flag to DELETE the table's data when the table is dropped. Otherwise, the data is not deleted.
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDDLFinal(flag As %Library.Boolean = 1, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the flag which determines if a class created by a DDL CREATE TABLE statement is Final.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide flag to define a class created by CREATE TABLE as Final. Otherwise, do not define the class as Final.
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    - The default setting is TRUE, the class will be defined as Final.
    - Temporary tables are always defined as Final, regardless of this setting.
    classmethod SetDDLIdentifierTranslations(from As %Library.String, to As %Library.String = "", ByRef oldfrom As %Library.String, ByRef oldto As %Library.String) as %Library.Status [ Language = objectscript ]
    Sets the DDL Identifier Translation mappings configuration settings.
    This is for filtering/modifying valid SQL identifier characters when translating SQL identifiers into Objects identifiers. When converting an SQL identifier to an Objects Identifier at DDL run time, the characters in the 'from' list will be converted to the characters in the 'to' list. This is done through the ObjectScript $Translate function. For example:
    SQL Table name = "My Table!"
    from = '"! '
    to = ''
    Class name = $Translate("My Table!",from,to) = MyTable

    Parameter:
    from
    A string of characters to translate from
    to
    A string of characters to translate to (by position in the string) Optional. Default is "".
    oldfrom
    Passed By Reference. Contains the previous value of the 'from' setting
    oldto
    Passed By Reference. Contains the previous value of the 'to' setting
    Returns:
    Status Code
    NOTES:
    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDDLNo201(flag As %Library.Boolean = 0, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the DDLNo201 configuration setting to [dis]allow CREATE TABLE for existing table. This flag determines if an SQLCODE -201 error is returned when the attempt is made to CREATE through DDL a table which already exists. The default is that an error is returned.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide configuration setting for the current configuration to not return an error if an attempt is made to CREATE a table through DDL that already exists. The existing table will be dropped, and then the CREATE TABLE will occur. Otherwise, return SQLCODE=-201. The default is 0 (FALSE).
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDDLNo30(flag As %Library.Boolean = 0, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the DDLNo30 configuration setting to [dis]allow DROP TABLE for a non-existing table. This flag determines if an SQLCODE -30 error is returned when the attempt is made to DROP through DDL a table which does not exists. The default is that an error is returned.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide configuration setting for the current configuration to not return an error if an attempt is made to DROP a non-existent table through DDL. Otherwise, return SQLCODE=-30. The default is 0 (FALSE).
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDDLNo307(flag As %Library.Boolean = 0, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the DDLNo307 configuration setting to [dis]allow DDL ADD PRIMARY KEY when the table already has an existing PRIMARY KEY. This flag determines if an SQLCODE -307 error is returned when an attempt is made to add through DDL a primary key constraint to a table which already has a primary key constraint defined. The default is that an error is returned.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide configuration setting for the current configuration to not return an error if an attempt is made add a primary key constraint to a table through DDL when a primary key constraint already exists for the table. The existing primary key constraint will be dropped, and then new primary key constraint added. Otherwise, return SQLCODE=-307. The default is 0 (FALSE).
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDDLNo311(flag As %Library.Boolean = 0, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the DDLNo311 configuration setting to [dis]allow DDL ADD FOREIGN KEY when existing FOREIGN KEY of the same name already exists for the table. This flag determines if an SQLCODE -311 error is returned when an attempt is made to create, through DDL, a foreign key constraint when a foreign key constraint with the same name already exists for the table. The default is that an error is returned.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide configuration setting for the current configuration to not return an error if an attempt is made to CREATE a duplicate foreign key constraint through DDL. Otherwise, return SQLCODE=-311. The default is 0 (FALSE).
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDDLNo315(flag As %Library.Boolean = 0, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the DDLNo315 configuration setting to [dis]allow DROP CONSTRAINT for non-existing constraint. This configuration setting determines if an SQLCODE -315 error is returned when the attempt is made to DROP, through DDL, a non-existing constraint. The default is that an error is returned.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide configuration setting for the current configuration to not return an error if an attempt is made to DROP a non-existent constraint through DDL. Otherwise, return SQLCODE=-315. The default is 0 (FALSE).
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDDLNo324(flag As %Library.Boolean = 0, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the DDLNo324 configuration setting to [dis]allow CREATE INDEX for existing index. This configuration setting determines if an SQLCODE -324 error is returned when an attempt is made to CREATE, through DDL, an index on a table which already has an index of the same name. The default is that an error is returned.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide configuration setting for the current configuration to not return an error if an attempt is made to CREATE an index through DDL that already exists. The existing index will be dropped, and then the CREATE INDEX will occur. Otherwise, return SQLCODE=-324. The default is 0 (FALSE).
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDDLNo333(flag As %Library.Boolean = 0, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the DDLNo333 configuration setting to [dis]allow DROP INDEX for non-existing index. This configuration setting determines if an SQLCODE -333 error is returned when an attempt is made to DROP, through DDL, a non-existing index. The default is that an error is returned.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide configuration setting for the current configuration to not return an error if an attempt is made to DROP a non-existent index through DDL. Otherwise, return SQLCODE=-333. The default is 0 (FALSE).
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDDLPKeyNotIDKey(flag As %Library.Boolean = 1, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Set configuration setting for PRIMARY KEY in DDL also being the IDKey index. This configuration setting determines if a primary key constraint, specified through DDL, also becomes the IDKey index in the class definition.
    By default, the primary key does NOT also become the IDKey index.
    Having the primary key index also be an IDKey index generally gives better performance, but it means the Primary key fields cannot be updated.

    Parameter:
    flag
    TRUE(1)/FALSE(0) If flag is TRUE (1), set the system wide configuration setting for the current configuration to NOT make Primary Key constraints become IDKey indices. If flag is FALSE (0), the Primary Key index will also become the IDKey index. The default is TRUE (1).
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDDLUseExtentSet(flag As %Library.Boolean = 1, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the flag which determines if a class created by a DDL CREATE TABLE statement defines the USEEXTENTSET class parameter to a value of 1. USEEXTENTSET=1 will generally bind the table to global names that allow for better performance when running queries against the table, especially when the index globals are used. It does mean the global names the class is mapped to are not names that attempt to match the classname. See documentation for USEEXTENTSET parameter for more information.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide flag to define a class created by CREATE TABLE to define the USEEXTENTSET class parameter to a value of 1. Otherwise, do not define the class with the USEEXTENTSET parameter.
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    - The default setting is TRUE, the class will use be defined with parameter USEEXTENTSET=1.
    classmethod SetDDLUseSequence(flag As %Library.Boolean = 1, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Sets the flag which determines if a class created by a DDL CREATE TABLE statement uses $Sequence for ID assignment. The storage keyword IDFUNCTION can be defined as INCREMENT or SEQUENCE. This keyword value is used by the class compiler to determine which system function - $increment or $sequence - is to be used for assigning new ID values for a persistent class using default storage. The default value for IDFUNCTION is INCREMENT, however the default behavior for classes defined through DDL is to define IDFUNCTION as SEQUENCE. To configure the system to have classes created through DDL to define IDFUNCTION as INCREMENT, pass in 0 for the flag parameter.

    Parameters:
    flag
    1 or 0. If TRUE, set the system wide flag to define a class created by CREATE TABLE uses $Sequence for ID assignment. Otherwise, do not define the class as Final.
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    - The default setting is TRUE, the class will use $Sequence for ID assignment.
    classmethod SetDefaultSchema(schema As %Library.String = "", ByRef oldval As %Library.String, Namespace As %Library.Boolean = 0) as %Library.Status [ Language = objectscript ]
    Sets the default schema used by SQL.
    This configuration setting provides the ability to define a default schema name other than SQLUser, the default. When an unqualified table name is encountered in an SQL statement (and there is no #import statement specified), the default schema will be used. You may specify _CURRENT_USER for the default schema name if you wish to use the SQL username the process logged in as the name of the default schema. If the process has not logged in to SQL, SQLUser will be used as the default schema name. You may also specify _CURRENT_USER/. In this case, if the process has not logged in to SQL, will be used as the default schema name. For example: _CURRENT_USER/HMO will use HMO as the default schema if the process has not logged in to SQL. This setting has nothing to do with the mappings between SQL schema names and the class package name, it only specifies the default schema.

    Parameter:
    schema
    String containing the default SQL schema name. If schema is "" or not defined, the default schema will be set to SQLUser.
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Namespace
    Boolean 1/0 flag. If TRUE, set the default schema for the current namespace only. The default for Namespace is FALSE
    Returns:
    Status Code
    NOTES:
    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    classmethod SetDefaultTimePrecision(value As %Library.Integer = 0, ByRef oldval As %Library.Integer) as %Library.Status [ Language = objectscript ]
    Set the Default precision for the Time component of the value returned by the GETDATE(), CURRENT_TIME, and CURRENT_TIMESTAMP SQL Scalar functions.

    Parameter:
    value
    Precision (number of decimal places for the millisecond portion of the time value). The default is 0, milliseconds are not returned in the values returned by the GETDATE(), CURRENT_TIME, and CURRENT_TIMESTAMP functions.
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:
    Status Code
    NOTES:
    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetDelimitedIdentifiers(flag As %Library.Boolean = 1, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Set the configuration setting which determines if double quote ("") in an SQL statement is used for delimited (quoted) identifiers or string constants. The default is delimited identifiers are supported.

    Parameter:
    flag
    TRUE(1)/FALSE(0) If flag is TRUE (1), "..." is treated as an identifier. If flag is FALSE (0), "..." is treated as a string literal. The default is TRUE (1).
    oldval
    Passed By Reference. Contains the previous value of the setting.
    Returns:

    Status Code

    NOTES:

    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will affect all processes immediately.
    - This is a system-wide setting.
    classmethod SetECPSync(flag As %Library.Boolean = 0, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Defines whether or not SQL SELECT statements perform a $SYSTEM.ECP.Sync() call in the OPEN code The default is ECP Sync is OFF.

    Parameter:
    flag
    TRUE(1)/FALSE(0) flag to define the setting to Perform ECP Syncs for Select queries. If TRUE (1), ECP Sync is turned on. If FALSE (0), ECP Sync is turned OFF.
    oldval
    Passed By Reference. Contains the previous value of the setting.

    Returns:

    Status Code

    Examples:

    • Set sc=$SYSTEM.SQL.SetECPSync(1) // ECP Sync ON
    • Set sc=$SYSTEM.SQL.SetECPSync(0,.oldval) // ECP Sync OFF
    NOTES:
    - You must have the "USE" permission on the %Admin Manage Resource in order to change this configuration setting.
    - Changing this configuration setting will only take effect for this process and new processes starting in InterSystems IRIS after this function is called. Any existing processes will still use the old setting.
    - The setting is on a per system basis.
    classmethod SetFastDistinct(flag As %Library.Boolean = 0, ByRef oldval As %Library.Boolean) as %Library.Status [ Language = objectscript ]
    Defines whether or not SQL DISTINCT is optimized to use indexes. The default is DISTINCT optimizations are ON.

    Parameter:
    flag
    TRUE(1)/FALSE(0) flag to define the setting to allow SQL optimizations of DISTINCT. If TRUE (1), DISTINCT optimization is turned on. If FALSE (0), DISTINCT optimiz