Re: Create a function that updates the record with and timestamps

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Create a function that updates the record with and timestamps
Дата
Msg-id 201003221732.45958.adrian.klaver@gmail.com
обсуждение исходный текст
Ответ на Re: Create a function that updates the record with and timestamps  (Chris Barnes <compuguruchrisbarnes@hotmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Tony Wasson
Дата:
Сообщение: Re: How to dump JUST procedures/funnctions?
Следующее
От: Neil Stlyz
Дата:
Сообщение: string functions and operators