User Tools

Site Tools

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

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]]

declare-condition

====== DECLARE CONDITION Statement - PL/HQL ====== You can use DECLARE CONDITION statement to declare a user-defined condition. Then you can define a handler for this condition using [[declare-handler|DECLARE HANDLER]], and raise the condition using the [[signal|SIGNAL]] statement. **Syntax**: <code language=sql> DECLARE condition_name CONDITION; </code> **Example:** Raise a condition if the number of rows is not equal to the specified number: <code language=sql> DECLARE cnt INT DEFAULT 0; DECLARE wrong_cnt_condition CONDITION; DECLARE EXIT HANDLER FOR wrong_cnt_condition PRINT 'Wrong number of rows'; SELECT COUNT(*) INTO cnt FROM TABLE (VALUES (1,2)); IF cnt <> 1 THEN SIGNAL wrong_cnt_condition; END IF; </code> **Compatibility:** IBM DB2, Teradata and MySQL. **Version**: PL/HQL 0.3.1 **See also:** * [[error-handling|Error Handling]] * [[declare-handler|DECLARE HANDLER]] * [[sqlcode|SQLCODE]] * [[sqlstate|SQLSTATE]] * [[get-diagnostics|GET DIAGNOSTICS]] * [[signal|SIGNAL]] * [[resignal|RESIGNAL]]