ERROR HANDLING

Translation reference for the conversion of BTEQ Error Handling to Snowflake Scripting equivalent

The BTEQ error handling capabilities are based on the Teradata Database error codes. These are the standard error codes and messages produced in response to user-specified Teradata SQL statements. A BTEQ user cannot change, modify or delete these messages.

For more information regarding BTEQ Error Handling, check here.

Sample Source Patterns

Basic BTEQ Error Handling Example

The error conditions content is relocated in different statements in case ERRORCODE is different to zero, otherwise it can be located as the original code. First, the query above the if statement is relocated within a BEGIN - END block, where in case of an exception it will be caught in the EXCEPTION block. Second of all, the ERRORCODE variable will be changed to the variable declared indicating their SQLCODE with an EWI indicating that the exact number of the SQLCODE is not the same as the ERRORCODE in BTEQ.

SELECT * FROM table1;
 
.IF ERRORCODE<>0 THEN .EXIT 1

.QUIT 0
EXECUTE IMMEDIATE
$$
  DECLARE
    STATUS_OBJECT OBJECT := OBJECT_CONSTRUCT('SQLCODE', 0);
  BEGIN
    BEGIN
      SELECT
        *
      FROM
        PUBLIC.table1;
      STATUS_OBJECT := OBJECT_CONSTRUCT('SQLROWCOUNT', SQLROWCOUNT);
    EXCEPTION
      WHEN OTHER THEN
        STATUS_OBJECT := OBJECT_CONSTRUCT('SQLCODE', SQLCODE, 'SQLERRM', SQLERRM, 'SQLSTATE', SQLSTATE);
    END;
    IF (STATUS_OBJECT['SQLCODE'] /*** MSC-WARNING - MSCEWI2075 - THE SNOWFLAKE ERROR CODE MISMATCH THE ORIGINAL TERADATA ERROR CODE ***/ != 0) THEN
      RETURN 1;
    END IF;
    RETURN 0;
  END
$$

Known Issues

No issues were found.

  • MSCEWI2075: The Snowflake error code mismatched the original Teradata error code.

Last updated