Azure DWH connector problem with post actions
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?