Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between oracle call and execute in context of error throwing

I have some procedure written in Oracle. Unfortunately I can't show its code. Somewhere inside it is select where execution crashed because of absence of required data. It looks like this

select value into l_value
        from config
       where code = upper(p_code);

So when I call this procedure like this (in SqlDeveloper)

execute some_package.some_procedure('CODE');

it throws

Error report -
ORA-01403: no data found
ORA-06512: at "XXXXXXXXXXXXXXXXXXX", line 111
ORA-06512: at "XXXXXXXXXXXXXXXXXXX", line 111
ORA-06512: at line 1
01403. 00000 -  "no data found"
*Cause:    No data was found from the objects.
*Action:   There was no data from the objects which may be due to end of fetch.

But when I call it like this

call some_package.some_procedure('CODE');

it crashes at the same place (as I can suggest from the result, stored in DB), but it does no throw an exception.

some_package.some_procedure('CODE') succeeded.

What happens? And why there is such difference?

like image 436
invenit Avatar asked Dec 04 '15 13:12

invenit


People also ask

What are the 2 functions for trapping exception?

Oracle uses two built in functions for catching exceptions and getting its information, SQLCODE and SQLERRM. SQLCODE: It returns the error number for the last encountered error. SQLERRM: It returns the actual error message of the last encountered error.

What are the two types of exceptions in PL SQL?

There are three types of exceptions: Predefined exceptions are error conditions that are defined by PL/SQL. Non-predefined exceptions include any standard TimesTen errors. User-defined exceptions are exceptions specific to your application.

How can you retrieve the error code and error message of any Oracle server exception?

Retrieving the Error Code and Error Message: SQLCODE and SQLERRM. In an exception handler, you can use the built-in functions SQLCODE and SQLERRM to find out which error occurred and to get the associated error message. For internal exceptions, SQLCODE returns the number of the Oracle error.

What are the methods there in save exceptions in Oracle?

Now With SAVE EXCEPTIONS COUNT SAVE EXCEPTIONS UPDATE employees SET first_name = enames_with_errors (indx); ROLLBACK; EXCEPTION WHEN std_errs. failure_in_forall THEN DBMS_OUTPUT. put_line (SQLERRM); DBMS_OUTPUT.


1 Answers

NO_DATA_FOUND exception behavior is special. It is handled by default in SQL context but not in PL/SQL. In SQL no data found is not considered as an error, it happens all the time that there is no data that meets certain condition.

CALL is SQL command whereas EXEC is a shortcut for BEGIN <code> END; which is PL/SQL.

like image 126
Husqvik Avatar answered Sep 25 '22 09:09

Husqvik