| From: | Josh Berkus <josh(at)agliodbs(dot)com> |
|---|---|
| To: | "Insyde" <insyde(at)insyde(dot)com(dot)br> |
| Cc: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: [BUGS] Problem when adding an existing primary key |
| Date: | 2003-02-03 18:25:17 |
| Message-ID: | 200302031025.17581.josh@agliodbs.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs pgsql-novice |
Ricardo,
I've moved our discussion over to the NOVICE list, because the BUGS list is
not the appropriate place for it.
EVERYONE: If anyone reading this speaks Brazillian Portuguese, please help
Ricardo out, ok?
> But what if I have a program and I want to show and error message to the
> user saying
> something like: "This registry already exists" and simply don't add?
> Instead, Postgres is
> closing the application! This should not happen. If I've got this message
> using psql OK,
> but inside my programs I should control the messages I what to display to
> the user, don't
> you think? Or, every time the user forget and insert a duplicated primary
> key, he will be
> obbligated to see postgres message?
That depends on how your application is written. You can take three
approaches:
1) Anticipation: You can have a script test for the primary key, and any
other required conditions of uniqueness, while the user's submission is still
in a buffer before calling an INSERT statement.
2) System-controlled keys: You can have the system assign the primary key and
take it out of the user's hands, thus preventing duplicates. In Postgres,
once does this using Sequences.
3) Error interception: You can have your interface code intercept error
messages coming from Postgresql, match the text, and return to the user a
more user-friendly error message.
I generally take an approach that is a combination of 1) and 2).
Unless I'm completely misunderstanding you, though, you need to build up your
basic knowledge of database application design. I do not know any books in
Brazillian, but for English, see the book review page:
http://techdocs.postgresql.org/techdocs/bookreviews.php
--
Josh Berkus
Aglio Database Solutions
San Francisco
| From | Date | Subject | |
|---|---|---|---|
| Next Message | pgsql-bugs | 2003-02-04 06:48:39 | Bug #890: only one user per process in libpq with krb5 auth |
| Previous Message | Insyde | 2003-02-03 10:52:26 | Re: Problem when adding an existing primary key |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrew McMillan | 2003-02-03 19:13:24 | Re: Can't connect to postgresql on win32 using Perl |
| Previous Message | Tom Lane | 2003-02-03 15:45:25 | Re: Database access problem : SOS |