SSC-FDM-PG0001

FOUND could have a different behavior in Snowflake in some scenarios.

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 FOUND property in PostgreSQL is a property based on the last executed query, it can be affected by some statements such as INSERT, UPDATE, DELETE, MERGE, SELECT INTO, PERFORM, FETCH and FOR loops. To read more details about this property, this is PostgreSQL documentation.

In Snowflake there is not a direct translation for this property, for the following scenarios:

  • INSERT

  • UPDATE

  • DELETE

  • MERGE

The converted code will be SQLFOUND Snowflake property (Here is the documentation) since it behaves like the PostgreSQL FOUND property.

For the other cases such as:

  • SELECT INTO

  • PERFORM

  • FETCH

The converted code will be a custom UDF (IS_FOUND_UDF) that behaves like the PostgreSQL FOUND property.

This happens because SQLFOUND changes its value only when at least one row is affected by the last executed query, if the last query does not change any row, it does not change.

While the IS_FOUND_UDF only works for statements that returns rows, if no row is returned it, it will return FALSE.

SQLFOUND Example

The last query affects a table, so the SQLFOUND is the closest to the PostgreSQL functionality.

IS_FOUND_UDF Example

The last query will return a row but does not change anything, so the IS_FOUND_UDF() is the closest to the PostgreSQL functionality.

IS_FOUND_UDF Source Code

Code Example

Insert Statement:

Update Statement:

Delete Statement:

Merge Statement:

Select Into Statement

Perform Statement:

Fetch Statement:

Recommendations

Last updated