Previous Topic

Next Topic

SQL Constants

The following constants can be used in queries:

Special Constant

Meaning

Now

Current date and time. This constant must be specified in quotes.

Note: This constant only works when used within the SQL date() function.

Current date (as ANSI date type)

Null

Indicates a missing or unknown value in a table.

Today

Current date. This constant must be specified in quotes.

Note: This constant only works when used within the SQL date() function.

current_date

Current date (as ANSI date type)

current_time

Current time

current_timestamp

Current date and time

local_time

Current time without time zone

local_timestamp

Current date and time without time zone

User

Effective user of the session (the Ingres user identifier, not the operating system user identifier).

current_user

Same as user.

system_user

Operating system user identifier of the user who started the session.

initial_user

Ingres user identifier in effect at the start of the session.

session_user

Same as user.

These constants can be used in queries and expressions. They can be used any number of times in a query, but the value is only materialized once per query execution. So a constant such as CURRENT_TIME can be referenced in an INSERT statement that inserts many rows, or an UPDATE statement that alters many rows, and the same time value will be used for each.

For example:

select date('now');

insert into sales_order
(item_number, clerk, billing_date)
values ('123', user, date('today')+date('7 days'));

update employee set e_sal = e_sal * 1.05, e_udp_time = CURRENT_TIMESTAMP where e_stat = 'x';

To specify the effective user at the start of a session, use the Ingres -u flag (for operating system commands) or the identified by clause of the SQL connect statement.


© 2007 Ingres Corporation. All rights reserved.