Re: Oracle 8.1.6 ProC and error codes , C++

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Sat, 21 Jul 2001 21:45:29 GMT
Message-ID: <th6li2blf8oldc_at_beta-news.demon.nl>


"Thomas Roemke" <TRoemke_at_gmx.de> wrote in message news:9evagc$tdu$01$1_at_news.t-online.com...
>
> "Reidel Jogie" <reidel_at_usa.net> schrieb im Newsbeitrag
> news:qRDQ6.33958$G5.7378552_at_news1.rdc1.md.home.com...
> > The values of sqlca.sqlcode correspond to the 'ORA' error codes (and
> > descriptions) in the Oracle Error Messages manual.
>
> Well, I know that the ora error messages are listed there, but from
> my "programmer's" point of view that doesn't help much.
>
> Some observations:
>
> First, I don't think that the people that developed the Oracle PL API
> thought
> the action
>
> if (0 > sqlca.sqlcode)
> {
> printErrorMessageAndExit();
> }
>
> would be the only action that makes sense after ANY error.
>
> Second, I don't think the same guys thought, a programmer would have
 to
> read
> the content of thousands of error descriptions to know which one to
 list
> in a
> switch statement like the following:
>
What's wrong with that? It has never hurt anyone!!!

> if (0 > sqlca.sqlcode)
> {
> switch (sqlca.sqlcode)
> {
> case -1: /* error 1 */ .... break;
> case -2: /* error 2 */ .... break;
> ......
> default: .... break;
> }
> }
>
> and furthermore - from oracle version to version - the programmer
 would
> have to read
> the manual again and would have to check if there are new error codes
> that ...
>

Again it has never hurt anyone!

> Finally, why would I have different error codes returned by the
> sqlca.sqlcode
> anyway, if I cannot use them? sqlca.sqlcode could just be a bool
 stating
>
> "an error has occured"
>
> and the error text can be used for logging purposes since it contains
> the error code
> as its first part ....
>
>
> Due to this observations, I think, there must be another way to handle
 these
> error conditions, but I simply don't know it.
>
> To the ProC programmers outside: How do you handle this in your programs?
>
> Thomas
>
>
>
>

[Quoted] You'r just asking for it!

By reading the Pro*C manual
[Quoted] which will tell you you can use exec sql whenever to address your errors It will also tell you the only 'warning' is -1403, meaning no data found (which can be handled by a exec sql whenever no_data_found) and all the other codes are true errors, which can always be dealt with by issuing a sqlerrm call.

[Quoted] There simply is no header file with all the error codes, which is probably on purpose as the error codes *and messages* are provided by the server. You could of course always design one yourself, but I don't think anyone has ever done this, if you want to use Pro*C you shouldn't start by hacking away.

Regards,

Sybrand Bakker, Oracle DBA Received on Sat Jul 21 2001 - 23:45:29 CEST

Original text of this message