From: Shavonne Marietta Wijesinghe <shavonne.marietta@studioform.it>
To: pgsql-sql@postgresql.org
Subject: Re: PRIMARY KEY
Date: Wed, 7 Mar 2007 14:16:14 +0100
Message-ID: <007301c760ba$c8acf470$1102a8c0@dream> (raw)
References: <003f01c760ac$c8d34980$1102a8c0@dream>
<45EEA8C5.9000507@gmail.com>
Thanks alot Mario. It did exactly what i wanted. I shall also take alook at the link you gave for more details..
Shavonne Wijesinghe
----- Original Message -----
From: M.P.Dankoor
To: Shavonne Marietta Wijesinghe
Cc: pgsql-sql@postgresql.org
Sent: Wednesday, March 07, 2007 12:57 PM
Subject: Re: [SQL] PRIMARY KEY
Hello,
Is it possible to redesign your table as follows:
create table Mod48_00_2007 (
ID text,
N_GEN serial not null,
FORMSTORE text,
COD_NOTATIO text,
PA_COGNOME text,
constraint pk_Mod48_00_2007 primary key (N_GEN)
);
Your insert simply becomes:
INSERT INTO MOD48_00_2007 (ID, FORMSTORE, COD_NOTAIO, PA_COGNOME) VALUES ('192168217200737122012', '', '00128', 'DE MARTINIS')
Do note that you do not refer to the N_GEN column, it will use the next value, please refer to http://www.postgresql.org/docs/8.1/interactive/datatype.html#DATATYPE-SERIAL
for more information.
Mario
Shavonne Marietta Wijesinghe wrote:
Hello
I have created a table
CREATE TABLE MOD48_00_2007 ( ID text, N_GEN int PRIMARY KEY, FORMSTORE text, COD_NOTAIO text, PA_COGNOME text);
And i insert the rows via a form in ASP. When the form loads i have a functin that goes and gets the value of the field N_GEN adds 1 to it and shows it to the user.
The problem is when i have 2 users working at the same time.
For example the last value in my field N_GEN is 2
When both the users A and B loads the form (ASP page) it sees N_GEN = 3 :)
So they fill in the form and user A clicks on the button OK and the record has been inserted with N_GEN = 3. But when the user B clicks on the button the record is not inserted because it has the same key "3"
INSERT INTO MOD48_00_2007 (ID, N_GEN, FORMSTORE, COD_NOTAIO, PA_COGNOME) VALUES ('192168217200737122012', '3', '', '00128', 'DE MARTINIS')
Is there any way i can do this automatically? i mean maybe i have to use someother property instead of "Primary Key" ??
Thanks
Shavonne Wijesinghe
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: shavonne.marietta@studioform.it
Subject: Re: PRIMARY KEY
In-Reply-To: <007301c760ba$c8acf470$1102a8c0@dream>
* 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