471,108 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,108 software developers and data experts.

custom error messages/numbers

Folks,

I am developing an app for PostgreSQL, entirely with stored functions (somewhat resembling the object-oriented approach. In fact it is not an app, just an API). All my functions return an integer value - 0 if the function wassuccessful, another value otherwise.

Until now, all parameter checking was done manually in the stored function (if param is null then return -8; end if; etc.) This makes things quite lengthy.

I know about check constraints. However, upon error they throw an error message and abort the current transaction, So my question is: is there any possible way of throwing my own error messages upon a check constraint violation?

Thank you very much

Zoltan Bartko

Nov 23 '05 #1
2 1614
BARTKO Zoltan wrote:
Folks,

I am developing an app for PostgreSQL, entirely with stored functions
(somewhat resembling the object-oriented approach. In fact it is not
an app, just an API). All my functions return an integer value - 0 if
the function was successful, another value otherwise.

Until now, all parameter checking was done manually in the stored
function (if param is null then return -8; end if; etc.) This makes
things quite lengthy.

I know about check constraints. However, upon error they throw an
error message and abort the current transaction, So my question is:
is there any possible way of throwing my own error messages upon a
check constraint violation?


Not in v7.4 - there should be nested transactions available in 7.5 which
might allow this. In fact, I think the developer of nested transactions
is looking for testers at the moment - see the hackers list for details.

In actual fact, I'd be tempted to move the procedural API out of the
database. If all your access is to be through the API and not using SQL
there seems little point in embedding it inside PG.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #2
On Thu, May 27, 2004 at 06:26:53PM +0200, BARTKO Zoltan wrote:
Folks,

I am developing an app for PostgreSQL, entirely with stored functions (somewhat resembling the object-oriented approach. In fact it is not an app, just an API). All my functions return an integer value - 0 if the function was successful, another value otherwise.

Until now, all parameter checking was done manually in the stored function (if param is null then return -8; end if; etc.) This makes things quite lengthy.

I know about check constraints. However, upon error they throw an error message and abort the current transaction, So my question is: is there any possible way of throwing my own error messages upon a check constraint violation?
I don't know if this does what you want, but maybe RAISE ERROR is what
you're looking for.

--
Martijn van Oosterhout <kl*****@svana.org> http://svana.org/kleptog/ Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAtlLIY5Twig3Ge+YRAmnDAKCn01+uvDCxYYiEU74SSq fuYe22XQCgtA6r
7CwR9/AfPUx5JrLKYl9VSAE=
=FCXf
-----END PGP SIGNATURE-----

Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Steve Jorgensen | last post: by
16 posts views Thread by Bret Pehrson | last post: by
2 posts views Thread by Pham Nguyen | last post: by
12 posts views Thread by soccertl | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.