tsequal

Description

Compares timestamp values to prevent update on a row that has been modified since it was selected for browsing.

Syntax

tsequal(browsed_row_timestamp, stored_row_timestamp)

Parameters

browsed_row_timestamp

is the timestamp column of the browsed row.

stored_row_timestamp

is the timestamp column of the stored row.

Examples

Example 1

Retrieves the timestamp column from the current version of the publishers table and compares it to the value in the timestamp column that has been saved. To add the timestamp column:

alter table publishers add timestamp

If the values in the two timestamp columns are equal, tsequal updates the row. If the values are not equal, tsequal returns the error message below:

update publishers
set city = "Springfield"
where pub_id = "0736"
and tsequal(timestamp, 0x0001000000002ea8)
Msg 532, Level 16, State 2:

Server 'server_name', Line 1:
The timestamp (changed to 0x0001000000002ea8) shows that the row has been updated by another user.
Command has been aborted.
(0 rows affected)

Usage


Timestamping a new table for browsing


Timestamping an existing table

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute tsequal.

See also

Datatype Timestamp datatype