Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 820462E00B7 for ; Mon, 11 Feb 2008 12:56:15 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 53867-04 for ; Mon, 11 Feb 2008 12:56:06 -0400 (AST) Received: from oxford.xeocode.com (unknown [62.232.55.118]) by postgresql.org (Postfix) with ESMTP id B74892E0031 for ; Mon, 11 Feb 2008 12:56:06 -0400 (AST) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.69) (envelope-from ) id 1JObwp-0001zg-SI; Mon, 11 Feb 2008 16:56:03 +0000 To: "Shavonne Marietta Wijesinghe" Cc: Subject: Re: Check before INSERT INTO In-Reply-To: <024301c86cca$591c9c60$3102a8c0@dream> (Shavonne Marietta Wijesinghe's message of "Mon\, 11 Feb 2008 17\:22\:50 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX" 63685) References: <010901c86ca6$3b66e870$3102a8c0@dream> <873arzscnu.fsf@oxford.xeocode.com> <024301c86cca$591c9c60$3102a8c0@dream> From: Gregory Stark Organization: EnterpriseDB Date: Mon, 11 Feb 2008 16:56:03 +0000 Message-ID: <87ve4vqvoc.fsf@oxford.xeocode.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/80 X-Sequence-Number: 30171 "Shavonne Marietta Wijesinghe" writes: > Thanks for the reply Grogory. I am trying to do a INSERT INTO. > > Here is my table. n_gen, n_sheet, tot_n_sheet are defined as Primary Key > (Serial not null) > id | n_gen | n_sheet | tot_n_sheet > ----------+-----------+-----------+------------- > a | 1 | 1 | 1 > b | 2 | 1 | 2 > x | 2 | 2 | 2 > u | 3 | 1 | 1 > r | 4 | 1 | 3 > a | 4 | 2 | 3 > s | 4 | 3 | 3 > > > So there are 2 users inserting in to the db. In my ASP page i have a field that > shows the value of n_gen +1. So when the 2 users both login at the same time, > with different sessions, they both see "7" in the n_gen field. But when they > click on the sumbit button only one record is inserted and the other is lost. > > I though it was possible to change the SQL string before it does the update.. > But i can't seem to find a solution for it.. Any idea ?? You'll have to explain what you want n_gen to contain. Then you'll have to decide whether you want to do this in ASP where you can certainly change the SQL all you like, or on the server where you can have triggers which change the values being stored or executing additional queries. -- Gregory Stark EnterpriseDB http://www.enterprisedb.com Ask me about EnterpriseDB's PostGIS support!