Re: Importing data w/ Unix timestamp

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: brianb-pggeneral(at)edsamail(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Importing data w/ Unix timestamp
Date: 2000-06-29 19:04:01
Message-ID: 1155.962305441@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu> writes:
> Another side comment: afaik an explicit conversion to abstime is not
> required to go from Unix time to timestamp. So
> insert into RealTable select uname, timestamp(timeinAsInt4),
> duration, etc from TempTable;
> should be equivalent.

Ah, right, that does work. Just to drift a little further off topic,
the locutions
timeinAsInt4::timestamp
cast (timeinAsInt4 as timestamp)
do not work, because in those cases the parser expects to find a
one-step conversion method, and there isn't one --- at least not in
the standard set of Postgres functions. The function-call syntax works
because there is a function timestamp(abstime) and the parser figures
out it can resolve the ambiguous function name timestamp() as that
function if it first applies int4-to-abstime coercion, which it knows
how to do.

In short: you can get a two-step type conversion from the function call
notation, but only one-step from cast notation.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-06-29 19:30:04 Re: pg_dump/load quoting.
Previous Message Mitch Vincent 2000-06-29 18:38:05 Trigger question.. (Heaptuple struct)