User Tools

Site Tools


Sidebar

**HPL/SQL is included to Apache Hive since version 2.0** * [[home|Home]]\\ * [[why|Why HPL/SQL]]\\ * [[features|Key Features]]\\ * [[start|Get Started]]\\ * [[doc|HPL/SQL Reference]]\\ * [[download|Download]]\\ * [[new|What's New]]\\ * [[about|About]]

resignal

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

====== RESIGNAL Statement - PL/HQL Reference====== RESIGNAL statement in used in a condition or exception handler to re-raise an error so it can be processed at a higher level. **Syntax**: <code language="sql"> RESIGNAL | RESIGNAL SQLSTATE [VALUE] sqlstate [SET MESSAGE_TEXT = message_text] </code> **Example 1:** Re-raise the same error: <code language="sql"> BEGIN DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN PRINT 'Error raised'; RESIGNAL; END; PRINT 'Before executing SQL'; SELECT * FROM abc.abc; -- Table does not exist, error will be raised PRINT 'After executing SQL - will not be printed in case of error'; END; </code> Result: <code> Before executing SQL Error raised </code> **Example 2:** Catch the re-raised condition in the outer condition handler: <code language="sql"> BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION PRINT 'Error raised, outer handler'; BEGIN DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN PRINT 'Error raised, resignal'; RESIGNAL; END; PRINT 'Before executing SQL'; SELECT * FROM abc.abc; -- Table does not exist, error will be raised PRINT 'After executing SQL - must not be printed'; END; PRINT 'Continue outer block after exiting inner'; END; </code> Result: <code> Before executing SQL Error raised, resignal Error raised, outer handler Continue outer block after exiting inner </code> **Example 3:** Re-raise a condition with the specified SQLSTATE and message text: <code language="sql"> BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN GET DIAGNOSTICS EXCEPTION 1 text = MESSAGE_TEXT; PRINT 'SQLSTATE: ' || SQLSTATE; PRINT 'Text: ' || text; END; BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION RESIGNAL SQLSTATE '02031' SET MESSAGE_TEXT = 'Some error'; SELECT * FROM abc.abc; -- Table does not exist, raise an exception END; END; </code> Result: <code> SQLSTATE: 02031 Text: Some error </code> **Compatibility**: IBM DB2, Teradata and MySQL **Version**: PL/HQL 0.03 **See also:** * [[error-handling|Error Handling]] * [[declare-condition|DECLARE CONDITION]] * [[declare-handler|DECLARE HANDLER]] * [[sqlcode|SQLCODE]] * [[sqlstate|SQLSTATE]] * [[get-diagnostics|GET DIAGNOSTICS]] * [[signal|SIGNAL]]