Create a function that updates the record with and timestamps

From: Chris Barnes <compuguruchrisbarnes(at)hotmail(dot)com>
To: Postgres General Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Create a function that updates the record with and timestamps
Date: 2010-03-22 16:58:49
Message-ID: BLU149-W2F208AB63B1569DDB94C9D4270@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I would like to have postgres update the last_modified column with the current_date on an update of the record.

I am not sure if there is a very simple way of doing this?

Or, do I need to create a function and a trigger to call the row and update with new data and set the last_modified to current_date?

Here is the table.

CREATE TABLE price.price_table (
PRICE_DATE DATE,
ID VARCHAR(13),
OPENING NUMERIC(18,6),
CLOSING NUMERIC(18,6),
HIGHEST NUMERIC(18,6),
LOWEST NUMERIC(18,6),
VOLUME BIGINT,
LAST_MODIFIED TIMESTAMP(6) WITHOUT TIME ZONE DEFAULT current_date,
CONSTRAINT PK_PRICE PRIMARY KEY (PRICE_DATE,ID));

Any help would be appreciated.

Cheers,

Chris



_________________________________________________________________
Take your contacts everywhere
http://go.microsoft.com/?linkid=9712959

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Szymon Guz 2010-03-22 17:06:40 Re: strange
Previous Message Tom Lane 2010-03-22 16:47:44 Re: Reducing excess files in pg_xlog