Skip to main content

Identifiers and Class Entity Names

Identifiers and Class Entity Names

SQL table names, view names, field names, index names, trigger names, and procedure names are used to generate corresponding persistent class entities by stripping out non-alphanumeric characters. The generated names of class entities and globals follow these translation rules.

Note:

Namespace names and SQL schema names and corresponding package names do not follow these translation rules.

  • Identifiers that differ only in their inclusion of punctuation characters are valid. Because class object names cannot include punctuation characters, InterSystems IRIS generates corresponding unique object names by stripping out all punctuation characters. If stripping out the punctuation characters of an identifier results in a non-unique class object name, InterSystems IRIS creates a unique name by replacing the last alphanumeric character with an incremented character suffix.

    For tables, views, fields, triggers, and procedure classmethod names, this is an integer suffix, beginning with 0. For example, myname and my_name generate myname and mynam0, adding my#name generates mynam1. If the number of generated unique names is larger than 10 (mynam9), additional names are generated by substituting a capital letter suffix, starting with A (mynamA). Because tables and views share the same name space, the same suffix counter is incremented for either a table or a view.

    For index names, this suffix is a capital letter, beginning with A. For example, myindex and my_index generate myindex and myindeA.

    If you have defined a name that ends in a suffix character (for example my_name0 or my_indexA, InterSystems IRIS handles unique name generation by incrementing to the next unused suffix.

  • Identifiers that have a punctuation character as the first character and a number as the second character are not valid for table names, view names, or procedure names. They are valid for field names and index names. If the first character of an SQL field name or index name is a punctuation character (% or _) and the second character is a number, InterSystems IRIS appends a lowercase “n” as the first character of the corresponding property name.

  • Identifiers that consist entirely of punctuation characters, or begin with two underscore characters (__name), or contains two pound signs together (nn##nn) are generally invalid as SQL entity names and should be avoided in all contexts.

You can configure translation of specific characters in SQL identifiers to other characters in corresponding object identifiers by creating a list of from/to character pairs. When converting an SQL identifier to an Objects identifier at DDL runtime, the characters in the “From” string are converted to the corresponding characters in the “To” string. These system-wide character translations facilitate the use of identifiers across environments where the rules for permitted identifier characters differ. Use the $SYSTEM.SQL.Util.SetDDLIdentifierTranslations()Opens in a new tab method to set from/to character pairings. To determine the current setting, call $SYSTEM.SQL.CurrentSettings()Opens in a new tab.

Specifying SQL Names in a Class Definition

When you define a persistent class that projects SQL entities, the name of each SQL entity are the same as the name of its corresponding persistent class definition element. To make an SQL table, field, or index name different, use the SqlTableName, SqlFieldName, or SqlName (for an index) keyword to specify the SQL name within your class definition. For example:

Property LName As %String [SqlFieldName = "Family#Name"];
Index NameIdx As %String [SqlName = "FullNameIndex"];
FeedbackOpens in a new tab