From lists@insyde.com.br Tue Apr 1 14:49:08 2003 X-Original-To: pgsql-odbc@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E32294762D7 for ; Tue, 1 Apr 2003 09:49:08 -0500 (EST) Received: from paiol.terra.com.br (paiol.terra.com.br [200.176.3.18]) by postgresql.org (Postfix) with ESMTP id EC1AB476237 for ; Tue, 1 Apr 2003 09:49:05 -0500 (EST) Received: from araci.terra.com.br (araci.terra.com.br [200.176.3.44]) by paiol.terra.com.br (Postfix) with ESMTP id 86003882EE for ; Tue, 1 Apr 2003 11:49:03 -0300 (BRT) Received: from insyde (200-171-250-132.customer.telesp.net.br [200.171.250.132]) (authenticated user insyde09) by araci.terra.com.br (Postfix) with ESMTP id 0BD74C412B for ; Tue, 1 Apr 2003 11:49:00 -0300 (BRT) Message-ID: <01a601c2f85e$08c15f20$84faabc8@insyde> From: "lists" To: Subject: problem with add Date: Tue, 1 Apr 2003 11:50:20 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_01A3_01C2F844.DF4B16E0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Status: No, hits=-0.1 required=5.0 tests=BAYES_30,HTML_40_50,RCVD_IN_OSIRUSOFT_COM,UPPERCASE_25_50 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/1 X-Sequence-Number: 2803 This is a multi-part message in MIME format. ------=_NextPart_000_01A3_01C2F844.DF4B16E0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable (this is a long post, sorry, but I have to explain the history) Hi, I've posted this some time ago, but I received an answer that do not satisfy me, and possibly others. What I'm trying to do is: I have a taable, say TBL1 built like this: CREATE TABLE TBL1 ( A INT, B CHAR(4), C CHAR(3) ); ALTER TABLE TBL1 ADD PRIMARY KEY ( A, B); Then I add some values to it, via ODBC INSERT INTO TBL1 (A,B,C) VALUES (1,'aaaa', 'bbb'); INSERT INTO TBL1 (A,B,C) VALUES (2,'aaaa', 'bbb'); INSERT INTO TBL1 (A,B,C) VALUES (3,'aaaa', 'bbb'); INSERT INTO TBL1 (A,B,C) VALUES (4,'aaaa', 'bbb'); INSERT INTO TBL1 (A,B,C) VALUES (5,'aaaa', 'bbb'); It's ok so far. But a new user of the system tries to insert a value that already exists: INSERT INTO TBL1 (A,B,C) VALUES (4,'aaaa', 'ccc'); then the program crashes!=20 You can say that I didn't treated the error, but I did treat the error, but the error code I was expecting (23000 - duplicated primary key) didn't came back. Instead an error message from the SGBD came. Is there any chance this would be corrected? Anyone else had the same problem/experience? Any work-around? If I know more programming, I would correct this, but I can't program. TIA, Ricardo. ------=_NextPart_000_01A3_01C2F844.DF4B16E0 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
(this is a long post, sorry, but I have to= explain=20 the history)
 
Hi,
 
I've posted this some time ago, but I rece= ived an=20 answer
that do not satisfy me, and possibly=20 others.
 
What I'm trying to do is:
 
I have a taable, say TBL1 built like=20 this:
 
CREATE TABLE TBL1 ( A INT,
       =20                = =20             B CHAR(4),<= /DIV>
           =             &nb= sp;           =20 C CHAR(3) );
ALTER TABLE TBL1 ADD PRIMARY KEY ( A,=20 B);
 
Then I add some values to it, via ODBC
 
INSERT INTO TBL1 (A,B,C) VALUES (1,'a= aaa',=20 'bbb');
INSERT INTO TBL1 (A,B,C) VALUES (2,'a= aaa',=20 'bbb');
INSERT INTO TBL1 (A,B,C) VALUES (3,'a= aaa',=20 'bbb');
INSERT INTO TBL1 (A,B,C) VALUES (4,'a= aaa',=20 'bbb');
INSERT INTO TBL1 (A,B,C) VALUES (5,'a= aaa',=20 'bbb');
 
It's ok so far.
 
But a new user of the system tries to inse= rt a=20 value that
already exists:
 
INSERT INTO TBL1 (A,B,C) VALUES (4,'a= aaa',=20 'ccc');
 
then the program crashes!
 
You can say that I didn't treated the error, but I did treat the=20 error,
but the error code I was expecting (23000 - duplicated primary key)
didn't came back. Instead an error message from the SGBD came.
 
Is there any chance this would be corrected? Anyone else had the same<= /DIV>
problem/experience? Any work-around?
 
If I know more programming, I would correct this, but I can't=20 program.
 
TIA,
Ricardo.
------=_NextPart_000_01A3_01C2F844.DF4B16E0-- From cgg007@yahoo.com Tue Apr 1 20:03:49 2003 X-Original-To: pgsql-odbc@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3DF59475AF8 for ; Tue, 1 Apr 2003 15:03:49 -0500 (EST) Received: from web13807.mail.yahoo.com (web13807.mail.yahoo.com [216.136.175.17]) by postgresql.org (Postfix) with SMTP id 48C16475EEE for ; Tue, 1 Apr 2003 15:03:46 -0500 (EST) Message-ID: <20030401200347.44895.qmail@web13807.mail.yahoo.com> Received: from [216.173.173.66] by web13807.mail.yahoo.com via HTTP; Tue, 01 Apr 2003 12:03:47 PST Date: Tue, 1 Apr 2003 12:03:47 -0800 (PST) From: Chris Gamache Reply-To: cgg007@yahoo.com Subject: Re: problem with add To: lists , pgsql-odbc@postgresql.org In-Reply-To: <01a601c2f85e$08c15f20$84faabc8@insyde> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-25.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,FROM_ENDS_IN_NUMS,IN_REP_TO, QUOTED_EMAIL_TEXT,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/5 X-Sequence-Number: 2807 You're leaving out several important details: PostgreSQL version PgSQL-ODBC version Client environment ... having said that ... Primary keys are implicitly "unique". To keep from getting an error on insert, "CREATE INDEX tbl1_idx ON tbl1 (a,b);" instead of making (a,b) a primary key... However, this will allow duplicate values in thost columns. If you NEED the values in those columns to be unique, then you will have to trap the error. Assuming you're using something like vbscript, use : on error resume next ...do query here... on error goto 0 if err.number <> 0 then ...it must have failed... end if Delphi use: try...except...end; etc... CG --- lists wrote: > (this is a long post, sorry, but I have to explain the history) > > Hi, > > I've posted this some time ago, but I received an answer > that do not satisfy me, and possibly others. > > What I'm trying to do is: > > I have a taable, say TBL1 built like this: > > CREATE TABLE TBL1 ( A INT, > B CHAR(4), > C CHAR(3) ); > ALTER TABLE TBL1 ADD PRIMARY KEY ( A, B); > > Then I add some values to it, via ODBC > > INSERT INTO TBL1 (A,B,C) VALUES (1,'aaaa', 'bbb'); > INSERT INTO TBL1 (A,B,C) VALUES (2,'aaaa', 'bbb'); > INSERT INTO TBL1 (A,B,C) VALUES (3,'aaaa', 'bbb'); > INSERT INTO TBL1 (A,B,C) VALUES (4,'aaaa', 'bbb'); > INSERT INTO TBL1 (A,B,C) VALUES (5,'aaaa', 'bbb'); > > It's ok so far. > > But a new user of the system tries to insert a value that > already exists: > > INSERT INTO TBL1 (A,B,C) VALUES (4,'aaaa', 'ccc'); > > then the program crashes! > > You can say that I didn't treated the error, but I did treat the error, > but the error code I was expecting (23000 - duplicated primary key) > didn't came back. Instead an error message from the SGBD came. > > Is there any chance this would be corrected? Anyone else had the same > problem/experience? Any work-around? > > If I know more programming, I would correct this, but I can't program. > > TIA, > Ricardo. > __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://platinum.yahoo.com