Is the re in the Redshift an equivalent of the following T-SQL snippet?
BEGIN TRY
{ sql_statement | statement_block }
END TRY
BEGIN CATCH
[ { sql_statement | statement_block } ]
END CATCH
[ ; ]
how would you handle an error in Redshift? For example I have got the following SQL code
begin;
drop table if exists [table_new];
drop table if exists [table_old];
create table [table_new] as
select * from [table_source];
alter table [current_table] rename to [table_old];
alter table [table_new] rename to [current_table];
commit;
Essentially the data is being picked up from the view and put into the table. If any of the sources in the view are empty that will cause an error and if I rerun the above code it returns the following.
[25P02] ERROR: current transaction is aborted, commands ignored until end of transaction block
Essentially, how to rollback the transaction on error?
Many thanks