Re: automatically updated an attribute with the current time

Поиск
Список
Период
Сортировка
От Jules Alberts
Тема Re: automatically updated an attribute with the current time
Дата
Msg-id 200201231136.g0NBa2M2006052@artemis.cuci.nl
обсуждение исходный текст
Ответ на automatically updated an attribute with the current time  ("Mark Bleeker" <mark@trilab.com>)
Ответы Re: automatically updated an attribute with the current time  ("Mark Bleeker" <mark@trilab.com>)
Список pgsql-novice
On 22 Jan 2002 at 12:02, Mark Bleeker wrote:
> Hello,
>
> I am trying to automatically update an attribute with the current time.
<snip>

from one newbie to another :)

i just figured it out yesterday:

-------------------------------------------------------
-- this is a templatetable, other tables inherit their
-- audit columns from it
drop table au_col;
create table au_col (
  mut_id varchar(100) not null default current_user,
  mut_timestamp timestamp not null default CURRENT_TIMESTAMP
);

-- function to change the values
drop function au_col();
create function au_col()
returns opaque
as  'begin
      old.mut_id = current_user;
      old.mut_timestamp = CURRENT_TIMESTAMP;
      return old;
    end;'
language 'plpgsql';

-- trigger to call the funtcion
drop trigger au_col on au_col;
create trigger au_col
  before update or delete -- create is covered by defaults
  on au_col
  for each row
  execute procedure au_col();
-------------------------------------------------------

HTH, HAND

--
Jules Alberts

В списке pgsql-novice по дате отправления:

Предыдущее
От: Mark Hesketh
Дата:
Сообщение: Re: Declaring constants in PG/PLSQL
Следующее
От: "Mark Bleeker"
Дата:
Сообщение: Re: automatically updated an attribute with the current time