NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
C-163
Examples—CURRENT
precision
is an unsigned integer in the range 1 through 6 that specifies the number of
significant digits with which the fraction of a second is expressed. The default is 6.
Examples—CURRENT
If you execute an SQL statement on February 20, 1996 at 11:30 pm that contains the
following call to CURRENT:
CURRENT YEAR TO DAY
the function returns the following value:
1996-02-20
CURRENT_TIMESTAMP Function
CURRENT_TIMESTAMP is an SQLCI function that returns a Julian timestamp in
Greenwich mean time for the current date and time. The data type of the returned value
is NUMERIC(18) or LARGEINT.
CURRENT_TIMESTAMP works in the SQLCI commands BREAK FOOTING,
BREAK TITLE, DETAIL, EXECUTE, PAGE FOOTING, PAGE TITLE, REPORT
FOOTING, REPORT TITLE, and SET PARAM. It does not work in DML statements or
other SQL statements.
Considerations—CURRENT_TIMESTAMP
CURRENT_TIMESTAMP in reports
In reports, CURRENT_TIMESTAMP returns a new value for each detail line
printed. If you want the value of a timestamp to remain constant throughout a report,
use CURRENT instead of CURRENT_TIMESTAMP. SQLCI determines the value
of CURRENT only once for each query. (For example, if you use CURRENT in a
report title and footing, the printed timestamp value is the same in both places.)
CURRENT returns a timestamp with data type DATETIME.
CURRENT_TIMESTAMP as a parameter value
If you specify CURRENT_TIMESTAMP as a parameter value in a SET PARAM or
EXECUTE, it returns a timestamp for the time SET PARAM or EXECUTE
executes. Note that the results depend on whether you set the parameter in SET
PARAM or EXECUTE.
For example, the following statements execute statement S (which uses parameter
?T) twice, using a different Julian timestamp for each execution:
EXECUTE S USING ?T=CURRENT_TIMESTAMP; EXECUTE S
USING ?T=CURRENT_TIMESTAMP;
CURRENT_TIMESTAMP