Compares timestamp values to prevent update on a row that has been modified since it was selected for browsing.
tsequal(browsed_row_timestamp, stored_row_timestamp)
is the timestamp column of the browsed row.
is the timestamp column of the stored row.
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. If the values in the two timestamp columns are equal, tsequal updates the row. If the values are not equal, tsequal returns this error message:
update publishers set city = "Springfield" where pub_id = "0736" and tsequal(timestamp, 0x0001000000002ea8)
tsequal, a system function, compares the timestamp column values to prevent an update on a row that has been modified since it was selected for browsing. For general information about system functions, see “System functions”.
tsequal allows you to use browse mode without calling the dbqual function in DB-Library. Browse mode supports the ability to perform updates while viewing data. It is used in front-end applications using Open Client and a host programming language. A table can be browsed if its rows have been timestamped.
To browse a table in a front-end application, append the for browse keywords to the end of the select statement sent to Adaptive Server. For example:
Start of select statement in an Open Client application ... for browse Completion of the Open Client application routine
Do not use tsequal in the where clause of a select statement; only in the where clause of insert and update statements where the rest of the where clause matches a single unique row.
If you use a timestamp column as a search clause, compare it like a regular varbinary column; that is, timestamp1 = timestamp2.
When creating a new table for browsing, include a column named timestamp in the table definition. The column is automatically assigned a datatype of timestamp; you do not have to specify its datatype. For example:
create table newtable(col1 int, timestamp, col3 char(7))
Whenever you insert or update a row, Adaptive Server timestamps it by automatically assigning a unique varbinary value to the timestamp column.
To prepare an existing table for browsing, add a column named timestamp using alter table. For example, to add a timestamp column with a NULL value to each existing row:
alter table oldtable add timestamp
To generate a timestamp, update each existing row without specifying new column values:
update oldtable set col1 = col1
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute tsequal.
Datatype Timestamp datatype
Copyright © 2005. Sybase Inc. All rights reserved. |