On Fri, Sep 25, 2009 at 3:26 PM, Evan Prodromou <[email protected]>wrote:

> Chris Fanning wrote:
>
>> I'm running postgresql 8.3 and I'm definitely no database wizz. :(
>>
>> Any pointers please?
>>
> The modified column is a timestamp; it's automatically updated by the
> database server in MySQL.
>
> It's a bad idea for client code to update it; it's supposed to be up to the
> db server.
>
> I guess PostgreSQL doesn't do that.
>
I guess it doesn't.
 http://www.postgresql.org/docs/8.2/static/plpgsql-trigger.html

# su postgres
$ createlang plpgsql statusnet

# vim a_pg_function.sql

CREATE FUNCTION confirm_time_stamp() RETURNS trigger AS $confirm_time_stamp$
    BEGIN
        -- Add time stamp to confirm_address:modify
        NEW.modified := current_timestamp;
        RETURN NEW;
    END;
$confirm_time_stamp$ LANGUAGE plpgsql;

CREATE TRIGGER confirm_time_stamp BEFORE INSERT OR UPDATE ON confirm_address
    FOR EACH ROW EXECUTE PROCEDURE confirm_time_stamp();



# psql -h localhost -U statusnet -d statusnet -f a_pg_function.sql

Now it seems to be working, at least I'm not getting the initial error.

Thanks.
Chris.


> -Evan
>
> --
> Evan Prodromou
> CEO, Control Yourself, Inc.
> [email protected] - http://identi.ca/evan - +1-514-554-3826
>
> _______________________________________________
> StatusNet-dev mailing list
> [email protected]
> http://lists.status.net/mailman/listinfo/statusnet-dev
>
_______________________________________________
StatusNet-dev mailing list
[email protected]
http://lists.status.net/mailman/listinfo/statusnet-dev

Reply via email to