Oracle Error Codes - Personalize Your Homepage

Personalize Your Homepage

Oracle Error Codes - Error Messages By Product - Messages, Descriptions, Causes and Recommended Actions

 

ErrorPro Logo

Python Exception Handling

The try statement- try and except keywords

Program below asks the user for input until a valid integer and handle ValueError exceptions.

>>> while True:
… try:
… x = int(raw_input(”Please enter a Integer: “))
… break
… except ValueError:
… print “Exception! That was no valid Integer.”

A try statement may have more than one except clause.

An except clause may include many exceptions.

Example:
… except (NameError, KeyError, ZeroDivisionError):
… pass

Search Python Error Code

Perl Exception Handling

Exception handling mechanism, the eval {} block.
Implemented by wrapping the code that needs to be executed around an eval block and the $@ variable is checked to see if an exception occurred.
syntax is:

eval {
….
};
if ($@) {
errorHandler($@);
}

Within the eval block, in case a syntax error or runtime error, or a die statement is executed, then an undefined value is returned by eval, and $@ is set to the error message.
No error, then $@ is null string.

Since the error message store in $@ is a simple scalar, checking the type of error that has occurred is error prone $@ does not tell where the exception occurred.

Starting from Perl 5.005, Exception Handling can be done:

eval {
open(FILE, $file) ||
die MyFileException->new(”Unable to open file - $file”);
};

if ($@) {
# now $@ contains the exception object of type MyFileException
print $@->getErrorMessage();
# where getErrorMessage() is a method in MyFileException class
}

MyFileException exception class can be built with as much functionality as desired.
You can get the calling context by using caller() in constructer of the exception class ( in general MyFileException::new()).

Search Perl Error Messages

Oracle Exception Handling

Oracle Predefined Exceptions, User Defined Exception, OTHERS errors handling

————————————————————————————————-
DECLARE
v_ErrorNumber NUMBER;
v_ErrorMessage VARCHAR2(500);
e_UserDefined EXCEPTION;
v_user_test number :=2;
BEGIN
/* PLSQL Code */
If v_user_test > 1 then
RAISE e_UserDefined;
End If;
EXCEPTION
–Oracle Predefined Exceptions
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE (’Select Into Statement No rows returned.’);
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (’Select Into Statement Return More Than One Row’);
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE (’Program attempts to divide a number by zero.’);
–User Defined Exception
WHEN e_UserDefined THEN
DBMS_OUTPUT.PUT_LINE (’User Defined Exception XYZ’);
–Handle all others errors
WHEN OTHERS THEN
v_ErrorNumber := SQLCODE;
v_ErrorMessage := SQLERRM;
–Print error information
DBMS_OUTPUT.PUT_LINE(’Error Number ‘||v_ErrorNumber||’ Message ‘||v_ErrorMessage);
/*
–or/and insert into Error Log Table
Insert Into
ERROR_LOG
(ERROR_CODE,MESSAGE,DATE,USER_NAME)
values
(
v_ErrorNumber,
v_ErrorMessage,
sysdate, –Current Date/time
USER –User executing program unit
);
*/
END;

————————————————————————————

Oracle Error Codes - Error Messages By Product

ORA-00001 unique constraint (string.string) violated

Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.

Action: Either remove the unique restriction or do not insert the key.

Commens:

In relational database design, a unique key or primary key is a candidate key to uniquely identify each row in a table. A unique key or primary key comprises a single column or set of columns. No two distinct rows in a table can have the same value (or combination of values) in those columns. Depending on its design, a table may have arbitrarily many unique keys but at most one primary key.

Oracle Error Codes - Error Messages By Product