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

if

====== IF Statement ====== IF statement executes a set of statements depending on the value of a boolean expression. HPL/HQL supports multiple syntaxes for IF statement. ===== IF - THEN - ELSIF/ELSEIF - ELSE - END IF ===== Syntax: <code language=sql> IF boolean_expression THEN statements [ELSIF | ELSEIF THEN statements ...] [ELSE statements] END IF; </code> **Example:** <code language=sql> IF state = 'CA' THEN code := 1; ELSIF state = 'NY' THEN code := 2; ELSIF state = 'MA' THEN code := 3; ELSE code := 5; END IF; </code> **Compatibility:** Oracle, Teradata, IBM DB2, MySQL, PostgreSQL, Netezza. **Version**: HPL/SQL 0.1 ===== IF - BEGIN - END - ELSE - BEGIN - END ===== Syntax: <code language=sql> IF boolean_expression single_statement | block [ELSE single_statement | block]; </code> **Example:** <code language=sql> IF state = 'CA' SET code = 1; ELSE SET code = 5; </code> <code language=sql> IF state = 'CA' BEGIN SET code = 1; SET type = 'A'; END ELSE BEGIN SET code = 5; SET type = 'B'; END </code> **Compatibility:** Microsoft SQL Server. **Version**: HPL/SQL 0.1 ===== .IF THEN ===== Syntax: <code language=sql> .IF boolean_expression THEN statement </code> **Example:** <code language=sql> .if errorcode <> 0 then .quit 1 </code> **Compatibility:** Teradata BTEQ **Version**: HPL/SQL 0.3.31