Home » SQL & PL/SQL » SQL & PL/SQL » Error handling when a function in a package is not found
Error handling when a function in a package is not found [message #278976] Tue, 06 November 2007 08:46 Go to next message
sama1261
Messages: 4
Registered: November 2007
Junior Member
In my cobol code i have the following lines

r_value := CMS_LIB.IS_DOUBLETTE_IN_IT
(d_issuer_nr,
d_kunde_nr,
d_karte_nr,
d_akst_nr,
to_date(d_belegdatum,'yyyymmddhh24miss'),
d_belegnummer,
d_betrag,
d_rayon_code,
d_kategorie_code
);

CMS_LIB is a package in my 10g Oracle database and IS_DOUBLETTE_IN_IT is a function in that package, where i m passing the above values e.g. d_issuer_nr, d_kunde_nr and so on.
i want to do error handling, so that if the particular function is not found in the package then an error message should be displayed.
can anyone tell me how to catch the exception if the function is not found in the package.

[Updated on: Tue, 06 November 2007 08:49]

Report message to a moderator

Re: Error handling when a function in a package is not found [message #278979 is a reply to message #278976] Tue, 06 November 2007 08:50 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Check the SQLCODE in when others.

By
Vamsi
Re: Error handling when a function in a package is not found [message #278985 is a reply to message #278976] Tue, 06 November 2007 09:06 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You can't, or at least not in the way you want.

You will get a compile error if your code references a procedure of function that does not exist - you won't get a runtime exception as your code will never be in a runnable condition.

What you can do is to put your call to CMS_LIB.IS_DOUBLETTE_IN_IT vis an EXECUTE IMMEDIATE, which will only get evaluated at runtime.

However, you really need to think twice about doing it this way.

Why don't you know if your packages exist at compile time, never mind whether they exist at run time?
Re: Error handling when a function in a package is not found [message #278996 is a reply to message #278985] Tue, 06 November 2007 09:34 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Oops Sad

By
Vamsi
Re: Error handling when a function in a package is not found [message #279075 is a reply to message #278996] Tue, 06 November 2007 18:28 Go to previous messageGo to next message
Seshagiri
Messages: 13
Registered: October 2007
Location: United Kingdom
Junior Member

I don't understand how you can say you want to handle if a particular function is not found in a package.

You will at any time are required to know which function you want to use and that it exists. There should be no error handling for whether or not a function exists in a package.

Don't consider using 'Execute Immediate' as well because people who come to maintain that program after you, will truly never know whether or that function exists as they are not even helped by the compile time error.

Re: Error handling when a function in a package is not found [message #279083 is a reply to message #278976] Tue, 06 November 2007 20:09 Go to previous messageGo to next message
Kevin Meade
Messages: 2101
Registered: December 1999
Location: Connecticut USA
Senior Member
maybe he means,

if his function does not find what was passed in?

Kevin
Re: Error handling when a function in a package is not found [message #279183 is a reply to message #279075] Wed, 07 November 2007 04:52 Go to previous messageGo to next message
sama1261
Messages: 4
Registered: November 2007
Junior Member
see if i have inserted a particular new function abc in my package p1. and now i call pi.abc then it is fine. but when i m moving my code from development to integration environment and in the integration environment i forget to include this new function in my package p1 then the program will abort. Also the developer will not come to know the reason for abend immediately. hence i would like to insert this error handling in my code.
Smile

Re: Error handling when a function in a package is not found [message #279189 is a reply to message #278985] Wed, 07 November 2007 05:01 Go to previous messageGo to next message
sama1261
Messages: 4
Registered: November 2007
Junior Member
thx for the advice...........


I will surely get a compile time error if i will compile the code in the development environment. But if i m in the integration environment then we dont compile the code. we just run the executables. hence there a run time chk has to be done.
Re: Error handling when a function in a package is not found [message #279243 is a reply to message #278976] Wed, 07 November 2007 08:10 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Hmmm in our environment, when a patched is moved into the "integration" database, an analyst or developer will log in and verify that everything works properly in that evnironment before passing it off to the customer for testing.

So hopefully we catch any objects that were missed in the patching process.

Re: Error handling when a function in a package is not found [message #279302 is a reply to message #279243] Wed, 07 November 2007 12:29 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Where I work we WANT our programs to abort when an installation is incomplete...

Imagine if it would not abort!

[Updated on: Wed, 07 November 2007 12:29]

Report message to a moderator

Re: Error handling when a function in a package is not found [message #279354 is a reply to message #279302] Wed, 07 November 2007 21:22 Go to previous messageGo to next message
sama1261
Messages: 4
Registered: November 2007
Junior Member
ya true...the program should abort and it will..........but the only thing i want to do is to make it easy for the developer or any new person who is working to know the reason for abend .............coz in our time and money project we cannot waste much time in error handling.....so i would like to give a message in the error file...........which we have(error file) in our application for all the modules.......hence i wanted to catch that exception....
Re: Error handling when a function in a package is not found [message #279395 is a reply to message #279354] Thu, 08 November 2007 01:38 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You could try saving coding and debugging time by tightening up your release procedures a bit
Re: Error handling when a function in a package is not found [message #279445 is a reply to message #278976] Thu, 08 November 2007 08:11 Go to previous message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Well the stack trace from the abort should be pretty obvious.

[Updated on: Thu, 08 November 2007 08:12]

Report message to a moderator

Previous Topic: check if oracle key word is used in a column (merged)
Next Topic: select count of nulls thru EXECUTE IMMEDIATE
Goto Forum:
  


Current Time: Sat Dec 03 16:07:32 CST 2016

Total time taken to generate the page: 0.04680 seconds