SSC-EWI-TD0023

ACTIVITY_COUNT inside SELECT/SET INTO VARIABLE requires manual fix

Important Notice: Migration of Documentation Website

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

Official Snowflake Snowconvert Documentation

For any immediate assistance or if you encounter any issues, please contact our support team at [email protected].

Thank you for your understanding.

Severity

Low

Description

The ACTIVITY_COUNT status variable returns the number of rows affected by an SQL DML statement in an embedded SQL or stored procedure application. For more information check here.

As explained in its translation specification, there is a workaround to emulate ACTIVITY_COUNT's behavior through:

SELECT $1 FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));

When using ACTIVITY_COUNT in a SELECT/SET INTO VARIABLE statement, it can not be simply replaced by the workaround mentioned above.

Example Code

Teradata

Snowflake

Manual Fix

Part of the workaround presented above can be used to still get the number of rows inserted/updated/deleted like this:

Instead of using the complete query, it needs to be adapted manually to Snowflake's SELECT INTO VARIABLE syntax.

Furthermore, if RESULT_SCAN(LAST_QUERY_ID()) is giving incorrect results, check SSC-FDM-TD0033 for how to handle possible limitations of using LAST_QUERY_ID.

Recommendations

  • Manually adapt the proposed workaround.

  • Check SSC-FDM-TD0033 for how to handle possible limitations of using LAST_QUERY_ID.

  • If you need more support, you can email us at [email protected]

Last updated