Can a Redshift stored procedure executing dynamic SQL use error exception handling to recover work & continue processing?

0

Within a Redshift stored procedure based solution, a table driven data quality assessment feature executes many dynamic SQL statements. In order to support the more complex rule definitions, users can pre-register an SQL statement that feasibly may contain syntax errors leading to a run time exception!

An EXCEPTION WHEN OTHERS clause can catch the failure however because the exception is rethrown on exiting the sub-procedure all the (useful) work performed prior to the exception is rolled back :-(.

Is it possible somehow, having "handled" the exception satisfactorily, to prevent the rethrow (and subsequent rollback) so the procedure can continue evaluating the remaining rules?

My guess this is technically precluded because Redshift stored procedure doesn't support sub-transactions ... and having pre-emptively cancelled the running transaction in order to commence the exception handler transaction - there is no way back? I expect using COMMIT WORK before each EXECUTE only addresses part of the problem given the caller will abend after the (first) exception occurs!

Is there a "state of the art" pattern known that can assist in cracking this use case?

질문됨 2년 전1217회 조회
1개 답변
0
수락된 답변

Thank you for posting your question, as of now Redshift doesn’t support the behavior you are trying to incorporate.
[Trapping errors] (https://docs.aws.amazon.com/redshift/latest/dg/stored-procedure-trapping-errors.html)
[Transaction Management] (https://docs.aws.amazon.com/redshift/latest/dg/stored-procedure-transaction-management.html)

Having said that I have raised a feature request with the service team on your behalf. While I am unable to comment on if/when this feature may get released, I request you to keep an eye on our [What's New] (https://aws.amazon.com/new/?whats-new-content-all.sort-by=item.additionalFields.postDateTime&whats-new-content-all.sort-order=desc&awsf.whats-new-analytics=*all&awsf.whats-new-app-integration=*all&awsf.whats-new-arvr=*all&awsf.whats-new-blockchain=*all&awsf.whats-new-business-applications=*all&awsf.whats-new-cloud-financial-management=*all&awsf.whats-new-compute=*all&awsf.whats-new-containers=*all&awsf.whats-new-customer-enablement=*all&awsf.whats-new-customer%20engagement=*all&awsf.whats-new-database=*all&awsf.whats-new-developer-tools=*all&awsf.whats-new-end-user-computing=*all&awsf.whats-new-mobile=*all&awsf.whats-new-gametech=*all&awsf.whats-new-iot=*all&awsf.whats-new-machine-learning=*all&awsf.whats-new-management-governance=*all&awsf.whats-new-media-services=*all&awsf.whats-new-migration-transfer=*all&awsf.whats-new-networking-content-delivery=*all&awsf.whats-new-quantum-tech=*all&awsf.whats-new-robotics=*all&awsf.whats-new-satellite=*all&awsf.whats-new-security-id-compliance=*all&awsf.whats-new-serverless=*all&awsf.whats-new-storage=*all) and Blog pages for any new feature announcements.

지원 엔지니어
답변함 2년 전
AWS
전문가
검토됨 2년 전
  • Thanks - I will monitor the blog and research a work-around / mitigation strategy until then :-). I anticipate this might require engineering for sub-transactions to work - which if provided would greatly enhance stored procedure based applications.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인