SAND CDBMS SQL Reference Guide
SAND CDBMS SQL Database Objects and Language Elements

 

Previous Topic:
Literals (Constants)
Chapter Index
Next Topic:
Nulls

 

Other SAND CDBMS SQL Language Elements


Special Constants

SAND CDBMS supports a number of special constants that can be used anywhere a regular constant can appear. These special constants represent variable values, such as current user, connection name, schema, or date/time information.

The special constants are the following:

CURRENT DATE
The current date (DATE data type format)

CURRENT SERVER
The current connection name (character string)

CURRENT SQLID
The current schema name (character string)

CURRENT TIME
The current time (TIME data type format)

CURRENT TIMESTAMP
The current timestamp (TIMESTAMP data type format)

USER
The current authorization identifier (character string)

The appearance of a space in the special constant indicates that any amount of whitespace may be used between the words in the constant. For instance, "CURRENT TIME" is equivalent to "CURRENT           TIME".

Example

CREATE TABLE invoice (iname VARCHAR(128),
                      iamount DEC(10,2),
                      idate DATE) ;

INSERT INTO invoice (iname, iamount, idate)
    VALUES (USER, 12.99, CURRENT DATE);

In this example, the values inserted into the invoice table are the current user name (USER), a numeric amount (12.99), and the current date (CURRENT DATE). Note that the idate column must have been defined as DATE only, otherwise a data type mismatch error will be returned when attempting the INSERT.

 

Previous Topic:
Literals (Constants)
Chapter Index
Next Topic:
Nulls