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

Auto increment field when updating?

From: Robin Keech <robin(at)dialogue(dot)co(dot)uk>
To: "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org>
Subject: Auto increment field when updating?
Date: 2000-02-16 11:08:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Hi,  hope you can help.  This may be a really stupid question, but here

I have a table called 'log'.  This keeps track of an ongoing process.
The process writes records to the 'log' table using a unique id.  If the
id does not exist then the process inserts, else it updates the existing
row.  Only some fields are written to each time the row is updated.
There is one field called 'count' that ONLY needs to increment every
time that particular row AND the field 'count' are updated.

I know that I can select the information, increment it and update it
back again, but is there any way of setting up the database to do this
automatically?  I am using PostgreSQL 6.5.



pgsql-sql by date

Next:From: sszaboDate: 2000-02-16 12:55:22
Subject: Re: pgsql-sql-digest V1 #499
Previous:From: Moray McConnachieDate: 2000-02-16 10:34:02
Subject: Re: [SQL] How to set up a simple relational database

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