| From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Cc: | Chris Barnes <compuguruchrisbarnes(at)hotmail(dot)com>, andreas(dot)kretschmer(at)schollglas(dot)com |
| Subject: | Re: Create a function that updates the record with and timestamps |
| Date: | 2010-03-23 00:32:45 |
| Message-ID: | 201003221732.45958.adrian.klaver@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(dot)klaver(at)gmail(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Neil Stlyz | 2010-03-23 01:20:57 | string functions and operators |
| Previous Message | Tony Wasson | 2010-03-22 23:57:08 | Re: How to dump JUST procedures/funnctions? |