From: Robin Keech <robin@dialogue.co.uk>
To: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: Auto increment field when updating?
Date: Wed, 16 Feb 2000 11:08:28 -0000
Message-ID: <31262893C5E5D2119C4900105A30B3A112D593@roadrunner.dialogue.net> (raw)
Hi, hope you can help. This may be a really stupid question, but here
goes....
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.
Thanks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: robin@dialogue.co.uk
Subject: Re: Auto increment field when updating?
In-Reply-To: <31262893C5E5D2119C4900105A30B3A112D593@roadrunner.dialogue.net>
References: <31262893C5E5D2119C4900105A30B3A112D593@roadrunner.dialogue.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox