Reference Guide > TDV SQL Script > SQL Language Concepts > Identifiers
 
Identifiers
An identifier is a user-defined unique name for an object in SQL Script.
Identifiers can contain one or more characters.
Identifiers must begin with an alphabetical character (a-z, A-Z).
After the initial character, the following characters are valid:
Alphanumeric characters: a-z, A-Z, 0-9
Separators: , (comma), ; (semicolon), ' ' (pairs of single quotes)
Special characters: _ (underscore), / (forward slash), $ (dollar sign), # (hash symbol)
An identifier cannot be a SQL Script keyword (see SQL Script Keywords), unless the keyword is escaped using double quotes.
Examples of declared variables whose names are SQL Script keywords:
DECLARE "VALUE" INTEGER;
DECLARE "CURSOR" CURSOR;
 
Here the SQL Script keywords VALUE and CURSOR are enclosed in double quotes.
Escaping an identifier with double quotes also allows it to contain characters that would otherwise not be legal, such as spaces, dashes, or characters from other languages.
Examples of declarations of variables that contain otherwise illegal characters:
DECLARE "First Name" VARCHAR(40);
DECLARE "% Returned" DOUBLE;
 
An identifier can be used for a procedure name, parameter name, cursor name, field name, variable name, cursor variable name, data type name, exception name, or label for a block (such as BEGIN/END, LOOP, WHILE, REPEAT, FOR, LEAVE, ITERATE)
TDV SQL Script resolves identifiers by a set of processing rules.
Identifiers are not case-sensitive.
Identifiers within SQL expressions are first evaluated by looking locally in the SQL context. If an identifier is resolved within the local SQL context, the SQL engine does not continue searching.
For example, identifier name matches in database columns in the SQL WHERE clause take precedence over the names of local variables, procedure names, or formal parameters.
If the identifier is not resolved in the local context, the search proceeds to parent contexts using the smallest prefix basis, moving outward to schema-level scope.
The SQL context space is not case-sensitive, so differences in capitalization do not distinguish names that match an identifier within the SQL context.
If no matches are found, an Undeclared Identifier error is returned.