Re: [SQL] Auto increment field when updating?

From: Peter Vazsonyi <neko(at)kredit(dot)sth(dot)szif(dot)hu>
To: Robin Keech <robin(at)dialogue(dot)co(dot)uk>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Auto increment field when updating?
Date: 2000-02-19 10:34:12
Message-ID: Pine.LNX.4.10.10002191122430.19112-100000@kredit.sth.szif.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I hope this helps:

=> create table test(a int4 NOT NULL DEFAULT 1, b text);
=> create function tg_test() returns opaque as '
-> declare x text;
-> begin
-> new.a=old.a+1;
-> return new;
-> end;' language 'plpgsql';
=> insert into test(b) values('a');
INSERT 770064 1
=> update test set b='b';
UPDATE 1
=> select * from test;
a|b
-+-
2|b
(1 row)

Before this U need a createlang plpgsql too.

--
nek;(

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Nicola Cisternino 2000-02-19 11:21:16 ...LIMIT CLAUSE
Previous Message Mohit Marwaha 2000-02-19 07:31:24