Exception handling in amazon redshift

Viewed 3677

Need to know in Redshift database if there is a option to capture error code or error message in the exception block similar to error code (SQLCODE) and error description(SQLERRM) in Oracle. Requirement is to capture the error code or error message occuring in procedure and insert it into error logging table. Kindly suggest.

1 Answers

The question is quiet old. I hope you managed to find what you were looking for. Im adding up this answer so this answer can help other people.

In an Amazon Redshift stored procedure, the only supported handler_statement is RAISE. Any error encountered during the execution automatically ends the entire stored procedure call and rolls back the transaction. This occurs because subtransactions are not supported.

SYNTAX :

[ <<label>> ]
[ DECLARE
  declarations ]
BEGIN
  statements
EXCEPTION
  WHEN OTHERS THEN
    handler_statements
END;   

For detail understanding, visit its Documentation.

Related