~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to contrib/spi/moddatetime.example

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
DROP TABLE mdt;
 
2
 
 
3
CREATE TABLE mdt (
 
4
        id              int4,
 
5
        idesc           text,
 
6
        moddate timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
 
7
);
 
8
 
 
9
CREATE TRIGGER mdt_moddatetime
 
10
        BEFORE UPDATE ON mdt
 
11
        FOR EACH ROW 
 
12
        EXECUTE PROCEDURE moddatetime (moddate);
 
13
 
 
14
INSERT INTO mdt VALUES (1, 'first');
 
15
INSERT INTO mdt VALUES (2, 'second');
 
16
INSERT INTO mdt VALUES (3, 'third');
 
17
 
 
18
SELECT * FROM mdt;
 
19
 
 
20
UPDATE mdt SET id = 4
 
21
        WHERE id = 1;
 
22
UPDATE mdt SET id = 5
 
23
        WHERE id = 2;
 
24
UPDATE mdt SET id = 6
 
25
        WHERE id = 3;
 
26
 
 
27
SELECT * FROM mdt;