PRIMARY KEY

From: "Shavonne Marietta Wijesinghe" <shavonne(dot)marietta(at)studioform(dot)it>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: PRIMARY KEY
Date: 2007-03-07 11:35:58
Message-ID: 003f01c760ac$c8d34980$1102a8c0@dream
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2007-03-07 11:51:07 Re: PRIMARY KEY
Previous Message gherzig 2007-03-07 03:28:57 Re: best index for ~ ordering?