Re: problem with add - Mailing list pgsql-odbc

From Chris Gamache
Subject Re: problem with add
Date
Msg-id 20030401200347.44895.qmail@web13807.mail.yahoo.com
Whole thread Raw
In response to problem with add  ("lists" <lists@insyde.com.br>)
List pgsql-odbc
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


pgsql-odbc by date:

Previous
From: Jeff Silberberg
Date:
Subject: Re: problem after upgrade ---
Next
From: "Thomas M. Parris"
Date:
Subject: just "read only" tables in MS-Access via ODBC