Azure DWH connector problem with post actions

Medjurecan, Fran 6 Reputation points
2020-11-20T18:03:18.063+00:00

I am using the JDBC connector in Databricks to write data from a data frame into an Azure Synapse table. I want to use a merge statement, but since this is not available in Synapse I am simulating it by writing the data into a temporary table first and then deploying a post action simulating a merge from the temp table into the target table.
I am trying to make that post action transactional and to catch errors if they happen, so I deploy a post action like the following:

              SET XACT_ABORT ON
                  BEGIN TRY
                    BEGIN TRANSACTION

                      INSERT INTO target_table....

                      UPDATE target_table.....

                      DELETE target_table....

             END TRY
             BEGIN CATCH
                DECLARE @ErrorNumber INT
                DECLARE @ErrorMessage NVARCHAR(4000)
                DECLARE @ErrorState INT

                IF @@TRANCOUNT>0
                    ROLLBACK

                SELECT 
                    @ErrorNumber = ERROR_NUMBER(),
                    @ErrorMessage = ERROR_MESSAGE(),
                    @ErrorState = ERROR_STATE()

                THROW @ErrorNumber, @ErrorMessage, @ErrorState

            END CATCH

However, I can't use throw without putting a semicolon in the end of the select statement, and whenever I use semicolons to deploy SQL code using this connector I get syntax errors.
What am I doing wrong here?

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,859 questions
Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,160 questions
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.