Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

Next:From: Nicola CisterninoDate: 2000-02-19 11:21:16
Subject: ...LIMIT CLAUSE
Previous:From: Mohit MarwahaDate: 2000-02-19 07:31:24
Subject:

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group