pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Gamache <cgg007@yahoo.com>
To: lists <lists@insyde.com.br>
To: pgsql-odbc@postgresql.org
Subject: Re: problem with add
Date: Tue, 1 Apr 2003 12:03:47 -0800 (PST)
Message-ID: <20030401200347.44895.qmail@web13807.mail.yahoo.com> (raw)
In-Reply-To: <01a601c2f85e$08c15f20$84faabc8@insyde>

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 <lists@insyde.com.br> 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




view thread (2+ messages)

Message-ID: <20030401200347.44895.qmail@web13807.mail.yahoo.com>
Permalink:  ../20030401200347.44895.qmail@web13807.mail.yahoo.com/
Also on:    postgresql.org/message-id/20030401200347.44895.qmail@web13807.mail.yahoo.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: cgg007@yahoo.com, lists@insyde.com.br
  Subject: Re: problem with add
  In-Reply-To: <20030401200347.44895.qmail@web13807.mail.yahoo.com>
  References: <01a601c2f85e$08c15f20$84faabc8@insyde> <20030401200347.44895.qmail@web13807.mail.yahoo.com>

* 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