Re: Timestamp Column.
Posted in 1998
Nils Myklebust wrote:
>
> On Wed, 29 Apr 1998 13:40:36 -0400, "Art S. Kagel"
> <kagel@bloomberg.com> wrote:
>
> >pedrocr@dicoruna.es wrote:
[Original question SNIPPED]
> >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,
> 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.
Actually, Nils, that is how WE use such timestamps. And yes with
USEOSTIME==0 the fractions are not updated. And you are correct that
even FRACTION(3) is not sufficient but many UNIX system clocks do not
support accurate resolution in the gettimeofday() function that
Informix uses when USEOSTIME==1 to take advantage of FRACTION(5). We
have variously just used a sequential fraction number until the second
changes, inserting a hard time into the timestamp and inserted with the
actual timestamp (either using the DEFAULT or using gettimeofday()
ourselves) and if a key clash occurs on the timestamp just bump it one
and try again depending on the data stream load.
Actually we use the datatime/timestamp concept here to develop a unique
key for news stories and other such data that have no natural unique
key but for which a serial number is impractical.
Art S. Kagel