turn:
Oracle abnormalities in RAISE
An exception is thrown by the three ways
1. By PL / SQL runtime engine
2. Use the RAISE statement
3. Call RAISE_APPLICATION_ERROR stored procedure
when a database error or PL / SQL occur at runtime, an exception is thrown engine automatically PL / SQL runtime. An exception may be thrown by the statement RAISE
RAISE exception_name;
explicitly thrown programmer unusual idiom processing statements, but are not limited to declare RAISE exception, it can throw any any exception. For example, you want to detect new runtime exception handler with TIMEOUT_ON_RESOURCE wrong, you simply use the following statement in your program:
RAISE TIMEOUT_ON_RESOUCE;
an example of an order entry such as the following, if when the order is less than the number of stocks is thrown abnormalities, and captures the exception, exception handling
the dECLARE
inventory_too_low the eXCEPTION;
--- other declaration statement
the BEGIN
the IF order_rec.qty> THEN inventory_rec.qty
the RAISE inventory_too_low;
the END the IF
the eXCEPTION
the WHEN inventory_too_low THEN
order_rec.staus: = 'backordered';
the END;
RAISE_APPLICATION_ERROR built-in function to throw an exception to the exception and gives an error number and error message. Custom exception of the default error number is +1, the default information is User_Defined_Exception. RAISE_APPLICATION_ERROR functions can be performed and the anomaly portion calls pl / sql program block, named explicitly thrown error number with special exceptions. Raise_application_error (error_number, message [, true , false]))
range of the error number is -20,000 to -20,999. The error message is a text string of up to 2048 bytes. TRUE and FALSE means is added (TRUE) into the stack error (ERROR STACK) or overwrite (overwrite) the error stack (FALSE). The default is FALSE.
As shown in the following code:
the IF THEN product_not_found
the RAISE_APPLICATION_ERROR (-20 123, 'Invald Product code', TRUE);
the END the IF;
-------------------------------------------------- ------------------------------------------------
when abnormal after the throw, control unconditionally to the anomaly, which means that the control can not return to where the exception happened, when the exception is handled and resolved, control returns to the next part of the statement is executed on a layer.
The BEGIN
the DECLARE
bad_credit Exception;
the BEGIN
the RAISE bad_credit;
- abnormal, control passes;
the EXCEPTION
the WHEN bad_credit THEN
DBMS_OUTPUT.PUT_LINE ( 'bad_credit');
the END;
post --bad_credit exception handling, control passes where
the EXCEPTION
the WHEN the OTHERS THEN
- Control go where no abnormal from bad_credit
- have been processed as bad_credit
END;
when an exception occurs, the block inside the exception handler does not, control is transferred to block one or propagated to the exception processing section.
The BEGIN
the DECLARE --- internal block starts
bad_credit Exception;
the BEGIN
the RAISE bad_credit;
- an abnormality occurs, the steering control;
the EXCEPTION
the WHEN ZERO_DIVIDE THEN - can not handle the exception bad_credite
DBMS_OUTPUT.PUT_LINE ( 'ZERO Divide by error');
the END - end of the inner block
- control can not reach here, because the exception is not resolved;
- abnormal part
the eXCEPTION
the WHEN the OTHERS THEN
- not resolved because bad_credit, control is transferred to here
END;
An exception is thrown by the three ways
1. By PL / SQL runtime engine
2. Use the RAISE statement
3. Call RAISE_APPLICATION_ERROR stored procedure
when a database error or PL / SQL occur at runtime, an exception is thrown engine automatically PL / SQL runtime. An exception may be thrown by the statement RAISE
RAISE exception_name;
explicitly thrown programmer unusual idiom processing statements, but are not limited to declare RAISE exception, it can throw any any exception. For example, you want to detect new runtime exception handler with TIMEOUT_ON_RESOURCE wrong, you simply use the following statement in your program:
RAISE TIMEOUT_ON_RESOUCE;
an example of an order entry such as the following, if when the order is less than the number of stocks is thrown abnormalities, and captures the exception, exception handling
the dECLARE
inventory_too_low the eXCEPTION;
--- other declaration statement
the BEGIN
the IF order_rec.qty> THEN inventory_rec.qty
the RAISE inventory_too_low;
the END the IF
the eXCEPTION
the WHEN inventory_too_low THEN
order_rec.staus: = 'backordered';
the END;
RAISE_APPLICATION_ERROR built-in function to throw an exception to the exception and gives an error number and error message. Custom exception of the default error number is +1, the default information is User_Defined_Exception. RAISE_APPLICATION_ERROR functions can be performed and the anomaly portion calls pl / sql program block, named explicitly thrown error number with special exceptions. Raise_application_error (error_number, message [, true , false]))
range of the error number is -20,000 to -20,999. The error message is a text string of up to 2048 bytes. TRUE and FALSE means is added (TRUE) into the stack error (ERROR STACK) or overwrite (overwrite) the error stack (FALSE). The default is FALSE.
As shown in the following code:
the IF THEN product_not_found
the RAISE_APPLICATION_ERROR (-20 123, 'Invald Product code', TRUE);
the END the IF;
-------------------------------------------------- ------------------------------------------------
when abnormal after the throw, control unconditionally to the anomaly, which means that the control can not return to where the exception happened, when the exception is handled and resolved, control returns to the next part of the statement is executed on a layer.
The BEGIN
the DECLARE
bad_credit Exception;
the BEGIN
the RAISE bad_credit;
- abnormal, control passes;
the EXCEPTION
the WHEN bad_credit THEN
DBMS_OUTPUT.PUT_LINE ( 'bad_credit');
the END;
post --bad_credit exception handling, control passes where
the EXCEPTION
the WHEN the OTHERS THEN
- Control go where no abnormal from bad_credit
- have been processed as bad_credit
END;
when an exception occurs, the block inside the exception handler does not, control is transferred to block one or propagated to the exception processing section.
The BEGIN
the DECLARE --- internal block starts
bad_credit Exception;
the BEGIN
the RAISE bad_credit;
- an abnormality occurs, the steering control;
the EXCEPTION
the WHEN ZERO_DIVIDE THEN - can not handle the exception bad_credite
DBMS_OUTPUT.PUT_LINE ( 'ZERO Divide by error');
the END - end of the inner block
- control can not reach here, because the exception is not resolved;
- abnormal part
the eXCEPTION
the WHEN the OTHERS THEN
- not resolved because bad_credit, control is transferred to here
END;