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