PL/SQL Identifiers and Literals
##############
Identifiers
--------------
Identifiers are names for PL/SQL objects such as constants, variables, exceptions, procedures, cursors, and reserved words.
Identifiers:
* Can be up to 30 characters in length
* Cannot include whitespace (space, tab, carriage return)
* Must start with a letter
* Can include a dollar sign ($), an underscore ( _ ), and a pound sign (#)
* Are not case-sensitive
If you enclose an identifier within double quotes, then all but the first of these rules are ignored. For example, the following declaration is valid:
DECLARE
"1 ^abc" VARCHAR2(100);
BEGIN
IF "1 ^abc" IS NULL THEN ...
END;
###############
Literals
---------------
Literals are specific values not represented by identifiers. For example, TRUE, 3.14159, 6.63E-34, `Moby Dick', and NULL are all literals of type Boolean, number, or string. There are no date or complex datatype literals as they are internal representations. Unlike the rest of PL/SQL, literals are case-sensitive. To embed single quotes within a string literal, place two single quotes next to each other. See the following table for examples.
Literal Actual Value
'That''s Entertainment!' That's Entertainment!
'"The Raven"' "The Raven"
'TZ="CDT6CST"' TZ='CDT6CST'
'''' '
'''hello world''' 'hello world'
'''''' ''
###############
eg:
DECLARE
stmt VARCHAR2(1024);
BEGIN
stmt := 'ALTER SESSION SET NLS_DATE_FORMAT=''yyyy-mm-dd hh24:mi:ss''';
EXECUTE IMMEDIATE stmt;
END;
阅读(1747) | 评论(0) | 转发(0) |