21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Changed in: 2.0<br />

Context variables<br />

Description: CURRENT_TIMESTAMP returns the current server date and time. In versions prior to 2.0, the fractional<br />

part used to be always “.0000”, giving an effective precision of 0 decimals. From <strong>Firebird</strong> 2.0 onward<br />

you can specify a precision when polling this variable. The default is 3 decimals, i.e. milliseconds precision.<br />

Type: TIMESTAMP<br />

Syntax:<br />

Examples:<br />

Notes:<br />

CURRENT_TIMESTAMP [(precision)]<br />

precision ::= 0 | 1 | 2 | 3<br />

The optional precision argument is not supported in ESQL.<br />

select current_timestamp from rdb$database<br />

-- returns e.g. 2008-08-13 14:20:19.6170<br />

select current_timestamp(2) from rdb$database<br />

-- returns e.g. 2008-08-13 14:20:23.1200<br />

• The default precision of CURRENT_TIME is still 0 decimals, so in <strong>Firebird</strong> 2.0 and up CURRENT_TIMESTAMP<br />

is no longer the exact sum of CURRENT_DATE and CURRENT_TIME, unless you explicitly specify a precision.<br />

• Within a PSQL module (procedure, trigger or executable block), the value of CURRENT_TIMESTAMP will<br />

remain constant every time it is read. If multiple modules call or trigger each other, the value will remain<br />

constant throughout the duration of the outermost module. If you need a progressing value in PSQL (e.g. to<br />

measure time intervals), use 'NOW'.<br />

Available in: DSQL, PSQL<br />

Added in: 1.5<br />

CURRENT_TRANSACTION<br />

Description: CURRENT_TRANSACTION contains the unique identifier of the current transaction.<br />

Type: INTEGER<br />

Examples:<br />

select current_transaction from rdb$database<br />

New.Txn_ID = current_transaction;<br />

The value of CURRENT_TRANSACTION is stored on the database header page and reset to 0 upon restore. It is<br />

incremented with every new transaction.<br />

111

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!