Apache Hive : HPL/SQL - SQLCODE

Last updated: August 12, 2026

Apache Hive : HPL/SQL - SQLCODE

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

SQLCODEResult
0Successful execution
Positive valuesWarning
Negative valuesError

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.

See also: