Re: Timestamp Column.
Posted in 1998
On Wed, 29 Apr 1998 13:40:36 -0400, "Art S. Kagel"
<kagel@bloomberg.com> wrote:
>pedrocr@dicoruna.es wrote:
>>
>> Hi all.
>>
>> I want to add a column of type timestamp in a table. (Informix Online 7.1)
>> It's posible?
>> In the manual i don't find the data type timestamp.
>> Is there a type timestamp?
>> How can i do?
>> Please help.
>> Thanks.
>
>Informix does not support type TIMESTAMP. You can use DATETIME along
>with a DEFAULT constraint and an UPDATE TRIGGER to implement
>automatically maintained timestamps. Try:
>
>create table mytable (>...
>timestamp DATETIME YEAR TO FRACTION(3) DEFAULT CURRENT,
>...
>);
>
>Art S. Kagel
You would have to set USEOSTIME or something like that in your config
file for this to work.
Question: Is fraction(3) enough to avoide two updates getting the same
timestamp value?
May be it would be possible to device a system with timestamp as an
integer that is increased by 1 for every update? I haven't thought it
through, but it may require more support in the application than would
be desirable.
If you want to use the timestamp for optimistic locking (isn't that
what it's ususally used for) an alternative is to update with a where
clause that includes all fields in the table (or all fields to be
updated) with their value at the time the row was read by the
application. That's not too hard to implement depending on the
language you use.
Nils Myklebust
NM Data AS
Norway
E-mail: Nils.Myklebust@nmdata.com
FAQ at: http://www.iiug.org/techinfo/faq/faq_top.html
(Now with ODBC info under "Third party products".)