Re: time to integer - Mailing list pgsql-general

From Soma Interesting
Subject Re: time to integer
Date
Msg-id 5.0.2.1.0.20010306113352.02d81a98@pop.telus.net
Whole thread Raw
In response to Re: time to integer  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
At 02:27 PM 3/6/2001 -0500, you wrote:
>date_part('epoch', timestamp) produces a Unix-style seconds count.
>
>                         regards, tom lane


Ok, thanks I misunderstood the directions and thought I had to use epoch
with the timestamp function somehow :)

this is my trigger and function:

CREATE FUNCTION oned_member_num() RETURNS OPAQUE AS '
         BEGIN
                 NEW.member_num := NEW.id + date_part('epoch', timestamp
'now');
                 RETURN new;
         END;'
LANGUAGE 'plpgsql';


CREATE TRIGGER oned_member_num
BEFORE INSERT
ON members
FOR EACH ROW
EXECUTE PROCEDURE oned_member_num();

I'm not 100% sure that a pl/pgsql function is the best/only solution here.
Is it overkill, or my only option?




pgsql-general by date:

Previous
From: Soma Interesting
Date:
Subject: Fwd: Re: time to integer
Next
From: "Brett W. McCoy"
Date:
Subject: Re: PHP and PostgresSQL beta