Sidebar

HPL/SQL is included to Apache Hive since version 2.0

sqlcode

SQLCODE

SQLCODE built-in variable contains the return code of the last SQL statement. The code can be zero (0), negative or positive:

SQLCODE Result
0 Successful execution
Positive values Warning
Negative values Error

Note:

  • SQLCODE 100 means row not found or end of cursor
DECLARE id INT;
DECLARE cur CURSOR FOR 'SELECT id FROM db.orders';
OPEN cur;
FETCH cur INTO id;
WHILE SQLCODE = 0 THEN
  FETCH cur INTO id;
END WHILE;
CLOSE cur;

Compatibility: IBM DB2, Teradata.

Version: HPL/SQL 0.1

See also: