Re: How to build a TRIGGER in POSTGERSQL - Mailing list pgsql-sql

From darcy@druid.net (D'Arcy J.M. Cain)
Subject Re: How to build a TRIGGER in POSTGERSQL
Date
Msg-id 20010619114308.716CC1A78@druid.net
Whole thread Raw
In response to How to build a TRIGGER in POSTGERSQL  (Ilan Fait <ilan@iweb.com>)
List pgsql-sql
Thus spake Ilan Fait
>       1) I need to build a trigger that every time I insert into the table
> one of the columns will  get +1 number.

The easiest way in PostgreSQL is to simply make the field a serial type.
 CREATE TABLE mytable (   id SERIAL PRIMARY KEY,   myname TEXT);

>         2) what is  equal to 'sysdate' (to get/put the system date in a
> table)  in PostGerSQL.

Again, the table definition can handle this.
 CREATE TABLE mytable (   id SERIAL PRIMARY KEY,   mydate DATE DEFAULT CURRENT_DATE,   myname TEXT);

You should check out the docs on the web site.  They are quite comprehensive.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Sequence behaviour.
Next
From: David BOURIAUD
Date:
Subject: About primary keys.