Re: [GENERAL] How do I save data and then raise an exception?

2008-10-07 Thread Rob Richardson
- From: Scott Marlowe [mailto:[EMAIL PROTECTED] Sent: Friday, October 03, 2008 4:59 PM To: Rob Richardson Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] How do I save data and then raise an exception? On Fri, Oct 3, 2008 at 1:48 PM, Rob Richardson [EMAIL PROTECTED] wrote: I didn't see

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-03 Thread Rob Richardson
From: Jaime Casanova [mailto:[EMAIL PROTECTED] Sent: Thu 10/2/2008 10:11 PM To: Alvaro Herrera Cc: Rob Richardson; pgsql-general@postgresql.org Subject: Re: [GENERAL] How do I save data and then raise an exception? On Thu, Oct 2, 2008 at 8:44 PM, Alvaro Herrera [EMAIL PROTECTED] wrote: Rob

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-03 Thread Tom Lane
Rob Richardson [EMAIL PROTECTED] writes: I think I just came up with a thoroughly ugly idea. The database supports an annealing shop, in which coils are assigned to charges. After the check fails, I end up with coils assigned to a charge that does not exist. I could set up a job that runs

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-03 Thread Rob Richardson
I save data and then raise an exception? Rob Richardson [EMAIL PROTECTED] writes: I think I just came up with a thoroughly ugly idea. The database supports an annealing shop, in which coils are assigned to charges. After the check fails, I end up with coils assigned to a charge that does

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-03 Thread Raymond O'Donnell
On 03/10/2008 14:52, Rob Richardson wrote: That's how it should have been done, but it wasn't. It's too late to change it now. If I make any change to the C++ code, I run into a But setting up a foreign key constrain is something you do in the database, not in the app - can't you do that?

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-03 Thread Rob Richardson
in Galway Cathedral! -Original Message- From: Raymond O'Donnell [mailto:[EMAIL PROTECTED] Sent: Friday, October 03, 2008 10:53 AM To: Rob Richardson Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] How do I save data and then raise an exception? On 03/10/2008 14:52, Rob Richardson wrote

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-03 Thread Blazej
I'm thinking of a Python script, of which there are several running on site. RobR -Original Message- From: Tom Lane [mailto:[EMAIL PROTECTED] Sent: Friday, October 03, 2008 8:47 AM To: Rob Richardson Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] How do I save data

Re: [GENERAL] How do I save data and then raise an exception? -- solved

2008-10-03 Thread Rob Richardson
My thanks to all who contributed thoughts about my question. I have put a two-part solution into place. The trigger function that fires when charges are inserted raises the exception, but leaves the possibility of dangling coils (coils with the numbers of charges that do not exist in the

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-03 Thread Scott Marlowe
On Fri, Oct 3, 2008 at 8:56 AM, Rob Richardson [EMAIL PROTECTED] wrote: No, because the application first saves the coils and then saves the charge. Setting up the foreign key constraint would prevent any coils from being saved because the charge record would never exist at the time the coil

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-03 Thread Rob Richardson
@postgresql.org Subject: Re: [GENERAL] How do I save data and then raise an exception? On Fri, Oct 3, 2008 at 8:56 AM, Rob Richardson [EMAIL PROTECTED] wrote: No, because the application first saves the coils and then saves the charge. Setting up the foreign key constraint would prevent any

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-03 Thread Scott Marlowe
On Fri, Oct 3, 2008 at 1:48 PM, Rob Richardson [EMAIL PROTECTED] wrote: I didn't see anything in the documentation about deferred constraints. Can you point to someplace where I can read about them? http://www.postgresql.org/docs/8.3/static/sql-createtable.html -- Sent via pgsql-general

[GENERAL] How do I save data and then raise an exception?

2008-10-02 Thread Rob Richardson
Greetings! The people who originally wrote the system I'm trying to work with did not know as much as they should have about working with databases, so I'm stuck with the following situation: The applicaton is written in C++ (MS Visual C++ 6, Windows XP, in case it matters). At one point, a

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-02 Thread Alvaro Herrera
Rob Richardson wrote: Here's what I need to do: IF query_check_fails THEN UPDATE some_table SET some_value = 0 WHERE some_condition_is_true; RAISE EXCEPTION 'Look, you idiot, do it right next time!'; END; I need the update to work, but I need to raise the exception so the C++

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-02 Thread Jaime Casanova
On Thu, Oct 2, 2008 at 8:44 PM, Alvaro Herrera [EMAIL PROTECTED] wrote: Rob Richardson wrote: Here's what I need to do: IF query_check_fails THEN UPDATE some_table SET some_value = 0 WHERE some_condition_is_true; RAISE EXCEPTION 'Look, you idiot, do it right next time!'; END; I

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-02 Thread Gurjeet Singh
On Fri, Oct 3, 2008 at 7:41 AM, Jaime Casanova [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 8:44 PM, Alvaro Herrera [EMAIL PROTECTED] wrote: Rob Richardson wrote: Here's what I need to do: IF query_check_fails THEN UPDATE some_table SET some_value = 0 WHERE

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-02 Thread Gurjeet Singh
On Fri, Oct 3, 2008 at 7:14 AM, Alvaro Herrera [EMAIL PROTECTED]wrote: Rob Richardson wrote: Here's what I need to do: IF query_check_fails THEN UPDATE some_table SET some_value = 0 WHERE some_condition_is_true; RAISE EXCEPTION 'Look, you idiot, do it right next time!'; END;

Re: [GENERAL] How do I save data and then raise an exception?

2008-10-02 Thread Klint Gore
Gurjeet Singh wrote: On Fri, Oct 3, 2008 at 7:14 AM, Alvaro Herrera [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Rob Richardson wrote: Here's what I need to do: IF query_check_fails THEN UPDATE some_table SET some_value = 0 WHERE