User Tools

Site Tools


Sidebar

HPL/SQL is included to Apache Hive since version 2.0

declare

This is an old revision of the document!


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

====== Declarations - PL/HQL Reference ====== You can declare variables using DECLARE block or statement. Note that you can mix both syntaxes in a single program. DECLARE blocks and statements can appear in any part of the program. ===== DECLARE Block ===== DECLARE block has the following syntax: <code language=sql> DECLARE var datatype [NOT NULL] [:= | = | DEFAULT expression]; ... </code> Example: <code> DECLARE code CHAR(10); status INT := 1; count SMALLINT = 0; limit INT DEFAULT 100; </code> **Compatibility:** Declaration block syntax is similar to Oracle PL/SQL, PostgreSQL PL/pgSQL and Netezza NZPLSQL. ===== DECLARE Statement ===== DECLARE statement has the following syntax: <code language=sql> DECLARE var [, var2, ...] [AS] datatype [:= | = | DEFAULT expression] [, ...]; </code> Example: <code language=sql> DECLARE code CHAR(10); DECLARE status, status2 INT DEFAULT 1; DECLARE count SMALLINT, limit INT DEFAULT 100; </code> **Compatibility:** Declaration statement syntax is similar to IBM DB2 SQL PL, Teradata, Microsoft SQL Server Transact-SQL and MySQL.