Links

MSCEWI4032

Bulk Insert Partially Translated

Severity

High

Description

This EWI is added to a literal that was originally a concatenation, when the contained code had a BULK INSERT statement. The PUT command resulting from the BULK INSERT translation is not supported when executing code that was originally Dynamic SQL.
For this reason, the PUT command must be extracted from the output code and executed manually outside of the procedure that contains it. Keep in mind that if there are many BULK INSERT statements in Dynamic SQL sentences within the procedure, it is advised to split this procedure in order to be able to manually execute the corresponding PUT command for each translated BULK INSERT.

Code Example

Input Code:

CREATE PROCEDURE [dbo].[Demo_Proc]
AS
BEGIN
...
...
SET @a = 'BULK INSERT ' + @e + ' FROM '''
+ @b + '''';
EXEC (@a);
END;

Output Code:

CREATE OR REPLACE PROCEDURE dbo.Demo_Proc ()
RETURNS STRING
LANGUAGE JAVASCRIPT
EXECUTE AS CALLER
AS
$$
...
...
A = // ** MSC-ERROR - MSCEWI4032 - THE BULK INSERT WAS PART OF A DYNAMIC SQL, WHICH MAKES SOME OF THE TRANSLATED ELEMENTS INVALID UNLESS EXECUTED OUTSIDE DYNAMIC CODE. **
`CREATE OR REPLACE FILE FORMAT FILE_FORMAT_637775071321116498;
CREATE OR REPLACE STAGE STAGE_637775071321116498
FILE_FORMAT = FILE_FORMAT_637775071321116498;
/*** MSC-ERROR - MSCEWI4033 - PUT IS NOT SUPPORTED INSIDE DYNAMIC SQL. EXECUTE OUTSIDE OF CONTAINING PROCEDURE WHERE APPLICABLE. ***/
PUT file://${B} @STAGE_637775071321116498 AUTO_COMPRESS = FALSE;
COPY INTO PUBLIC.${E} FROM @STAGE_637775071321116498/${B}`;
EXEC(`${A}`);
$$;

Recommendations

  • Extract the PUT command that resulted from the Dynamic BULK INSERT statement, and execute it before calling the procedure.
  • For more support, you can email us at [email protected] or post a message to our forums. If you have a contract for support with Mobilize.Net, reach out to your sales engineer and they can direct your support needs.
Last modified 10mo ago