Re: Create a function that updates the record with and timestamps - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Create a function that updates the record with and timestamps
Date
Msg-id 201003221732.45958.adrian.klaver@gmail.com
Whole thread Raw
In response to Re: Create a function that updates the record with and timestamps  (Chris Barnes <compuguruchrisbarnes@hotmail.com>)
List pgsql-general
On Monday 22 March 2010 10:55:36 am Chris Barnes wrote:
> I see examples for updating tables using a function, but I would like to
> pull the row requested and modify the last_modified column with
> current_date and push the modified data back into the same row.
>
>
>
> I did see an example of how to use old and new at this at this link, but it
> is vague.
>
>
>
> http://www.faqs.org/docs/ppbook/x20655.htm#TRIGGERFUNCTIONVARIABLES
>


Something like this:

CREATE OR REPLACE FUNCTION public.ts_update()
  RETURNS trigger AS

$Body$
BEGIN
NEW.ts_update:=timeofday();
RETURN NEW;
END;
$Body$
  LANGUAGE 'plpgsql';


--
Adrian Klaver
adrian.klaver@gmail.com

pgsql-general by date:

Previous
From: Tony Wasson
Date:
Subject: Re: How to dump JUST procedures/funnctions?
Next
From: Neil Stlyz
Date:
Subject: string functions and operators