Hello Experts,
In my company, we are currently developing an ETL to migrate data from an oracle database to a HANA database.
Lately we encountered this issue where an error occurred in procedure DM_INVOICE as shown below.
Now the error was because of the unique constraint violation on table EX_INVOICE_HEADER.
We found the problem and fixed it... that wasn't a problem.
But the thing is that we are logging each and every error that might occur by doing exception handlings on all procedures that we have.
Only on this error the exception handling was not fired and did not process the contents of the handler to be able to save the log.
Could not execute 'call dm_run('PBG','Initial',null,null)' in 34:48.653 minutes .
SAP DBTech JDBC: [2048]: column store error: [2048] "MX_DAN"."DM_RUN": line 191 col 3 (at pos 8393): [2048] (range 3): column store error: [2048] "MX_DAN"."DM_ETL": line 153 col 5 (at pos 7045): [2048] (range 3): column store error: search table error: [2620] "MX_DAN"."DM_INVOICE": line 29 col 3 (at pos 1028): [130] (range 2) InternalFatal exception: incorrect CESU-8 string: 'unique constraint violated: TrexUpdate failed on table 'MX_DAN:EX_INVOICE_HEADER' with error: unique constraint violation for table MX_DAN:EX_INVOICE_HEADER$delta_1$en, constraint='$uc_UNI_B95E70F6$', value='V g¬öÏ Ÿá', pos=7; indexname=UNI_B95E70F6, rc=55'
Here's how we are doing the exception handling and the logging:
the DM_CREATE_LOG insert a record in table DM_LOG and it use autonomous transaction method to save the changes even when errors occur.
the DM_CREATE_LOG saves a FATAL error message whenever an error occurs,
except for when this error occured, it is as if the code inside the exit handler was not executed at all.
So, any idea why for the above error the exception handling code was not fired?
CREATE PROCEDURE DM_INVOICE (p_tenant_fk VARBINARY(16), p_system_source_fk VARBINARY(16), p_job_run_fk VARBINARY(16), p_module_fk VARBINARY(16))
LANGUAGE SQLSCRIPT SQL SECURITY INVOKER AS
v_err_msg NVARCHAR(4000);
BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN v_err_msg := ::SQL_ERROR_CODE ||' '|| ::SQL_ERROR_MESSAGE; CALL DM_CREATE_LOG ('FATAL',:v_err_msg, NULL, NULL, :p_job_run_fk, :p_module_fk); raise_hana_error(:v_err_msg); END; CALL DM_CREATE_LOG ('INFO','Inserting into table ex_invoice_header', NULL, NULL, :p_job_run_fk, :p_module_fk); --insert new records INSERT INTO ex_invoice_header (guid, ... ) SELECT id.invoice_header_fk, ... FROM dm_l_invoice_dim id WHERE UPPER(id.ui)= 'I' AND id.src_rank = 1;
END;
Regards,
Dany