473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 1683
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Steve Jorgensen | last post by:
If you've ever employed custom error numbers and messages in you programs, you've probably ended up with code similar to what I've ended up with in the past something like... <code> public...
7
by: Steve Jorgensen | last post by:
Here is some code to generate code for raising and getting information about custom errors in an application. Executing the GenerateXyzErrDefs procedure generates the code. <tblXyzError>...
16
by: Bret Pehrson | last post by:
I've converted a non-trivial C++ library to managed, and get the following unhelpful linker error: Assignment.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are...
2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
3
by: Brad Wood | last post by:
If I add my own section to my Web.Config file of my (2.0) web service project (and refer to it by adding a "section" sub-element to a "configSections" element, I then get information messages...
12
by: soccertl | last post by:
Is there a listing of what the compile errors mean? For example: "hdb_log.c", line 163.22: 1506-046 (S) Syntax error. "hdb_log.c", line 160.20: 1506-098 (E) Missing argument(s). make: 1254-004...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.