XML file as a stored procedure input parameter?

215 Views Asked by At

My current requirement has a scenario where I need to perform bulk inserts or batch inserts into two SAP HANA tables using a stored procedure as a reusable component.

I wanted to know if there is a method in which I can accept a XML object as an input parameter which can be iterated through to make the insert within the stored procedure or an XSJS script.

Or if there is any other way to do a batch / bulk insert into SAP HANA tables using input parameters.

1

There are 1 best solutions below

1
On

I'm not aware of any XML processing feature that would allow to efficiently do what you are describing.

For bulk data processing where the bulk data should be handed over to a procedure via a parameter, the "pattern" I have seen used most often is that of a intermediate loading table.

With this pattern, the DB client loads the data into an intermediate loading/staging table (which may be a temporary table) and then provides the name of this table as a table input parameter to the procedure. The procedure can access the table by the parameter name and does not need to know the actual table name.

Using temporary tables for the loading/staging table removes the need for handling aborted loads as either both the table definition and the data (for local temporary tables) or just the session specific data (for glocal temporary tables) get deleted upon session disconnect.

This approach is based on that the to-be inserted data can be correctly represented by a table. As XML data can be quite a lot more complex, the transformation from XML -> table form needs to be done before insertion.