Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 6BBEA2E009A for ; Mon, 11 Feb 2008 08:04:28 -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 21246-01 for ; Mon, 11 Feb 2008 08:04:06 -0400 (AST) Received: from smtpout26.attiva.biz (smtpout26.attiva.biz [85.37.16.27]) by postgresql.org (Postfix) with ESMTP id C7F912E008F for ; Mon, 11 Feb 2008 08:04:12 -0400 (AST) Received: from FBCMFE02B15.fbc.local ([192.168.30.161]) by smtpout26.attiva.biz with Microsoft SMTPSVC(6.0.3790.1830); Mon, 11 Feb 2008 13:04:10 +0100 Received: from dream ([88.34.161.130]) by FBCMFE02B15.fbc.local with Microsoft SMTPSVC(6.0.3790.1830); Mon, 11 Feb 2008 13:04:09 +0100 Message-ID: <010901c86ca6$3b66e870$3102a8c0@dream> Reply-To: "Shavonne Marietta Wijesinghe" From: "Shavonne Marietta Wijesinghe" To: Subject: Check before INSERT INTO Date: Mon, 11 Feb 2008 13:04:18 +0100 Organization: Studio FORM MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0106_01C86CAE.9C7D3620" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-OriginalArrivalTime: 11 Feb 2008 12:04:09.0698 (UTC) FILETIME=[35704420:01C86CA6] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/76 X-Sequence-Number: 30167 This is a multi-part message in MIME format. ------=_NextPart_000_0106_01C86CAE.9C7D3620 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable My table structure CREATE TABLE my_shevi ( id text, n_gen serial NOT NULL, n_sheet serial NOT NULL, tot_sheet serial NOT NULL, CONSTRAINT my_shevi_pkey PRIMARY KEY (n_gen, n_sheet, tot_sheet) )=20 WITH OIDS; ALTER TABLE my_shevi OWNER TO postgres; The user updates the DB via ASP. When 2 users click on the submit button = at the same time, only 1 record is inserted. (ERROR: duplicate key = violates unique constraint "my_shevi_pkey") For example they both send a string like below. strSQL =3D INSERT INTO my_shevi VALUES ('a', 4, 1, 1); I thought of adding a test before executing the insert into.=20 Set SQLN_GEN =3D oConn.Execute("SELECT upper(N_GEN), upper(N_SHEET), = upper(TOT_N_SHEET) FROM " & TableName & " WHERE N_GEN=3D'" & n_gen & "' = AND N_SHEET=3D'" & n_sheet & "' AND TOT_N_SHEET=3D'" & tot_n_sheet & = "'") if (not SQLN_GEN.eof) then ***** set n_gen + 1 =20 else ***** leave n_gen the way it is end if conn.Execute strSQL But how can i ask it to change the n_gen value??? (The part with the = *****)=20 Thanks Shavonne Wijesinghe ------=_NextPart_000_0106_01C86CAE.9C7D3620 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
My table structure
 
CREATE TABLE = my_shevi
(
  id=20 text,
  n_gen serial NOT NULL,
  n_sheet serial NOT=20 NULL,
  tot_sheet serial NOT NULL,
  CONSTRAINT = my_shevi_pkey=20 PRIMARY KEY (n_gen, n_sheet, tot_sheet)
)
WITH OIDS;
ALTER = TABLE=20 my_shevi OWNER TO postgres;
 
The user updates the DB via ASP. When 2 = users click=20 on the submit button at the same time, only 1 record is inserted. = (ERROR: =20 duplicate key violates unique constraint "my_shevi_pkey")
 
For example they both send a string = like=20 below.
strSQL =3D INSERT INTO my_shevi = VALUES ('a',=20 4, 1, 1);
 
I thought of adding a test before executing the insert=20 into. 
 
Set SQLN_GEN =3D oConn.Execute("SELECT = upper(N_GEN),=20 upper(N_SHEET), upper(TOT_N_SHEET) FROM " & TableName & " WHERE = N_GEN=3D'"=20 & n_gen & "' AND N_SHEET=3D'" & n_sheet & "' AND = TOT_N_SHEET=3D'"=20 & tot_n_sheet & "'")
 
if (not SQLN_GEN.eof)=20 then
     ***** set n_gen + = 1  
else

     ***** leave = n_gen the=20 way it is
end if
 
conn.Execute strSQL

But how can i ask it to change the n_gen value??? (The part = with the=20 *****)
 
Thanks
 
Shavonne = Wijesinghe
------=_NextPart_000_0106_01C86CAE.9C7D3620--