MSCEWI3047

TO_NCHAR transformed to TO_VARCHAR, it may not be compilable in Snowflake.

This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.

Severity

Low

Description

This warning is added when the function TO_NCHAR was found and it was transformed into a TO_VARCHAR function.

There are multiple cases where the transformation causes a compilation error, or the output is not the same.

Example Code

Input Code:

select TO_NCHAR(sysdate,'DY','nls_date_language=english') from dual

Output Code:

select
/*** MSC-WARNING - MSCEWI3047 - TO_NCHAR TRANSFORMED TO TO_VARCHAR, IT MAY NOT BE COMPILABLE IN SNOWFLAKE ***/
TO_VARCHAR(CURRENT_DATE,'DY','nls_date_language=english')
from dual;

The example from above will result in an error if it is used in Snowflake.

Not all cases are causing errors

Input Code:

SELECT TO_NCHAR(SYSDATE, 'YYYY-MM-DD') FROM dual;

Output Code:

SELECT
/*** MSC-WARNING - MSCEWI3047 - TO_NCHAR TRANSFORMED TO TO_VARCHAR, IT MAY NOT BE COMPILABLE IN SNOWFLAKE ***/
TO_VARCHAR(CURRENT_DATE, 'YYYY-MM-DD')
FROM dual;

The last example does not cause an error in Snowflake, and the output is equivalent if executed.

Recommendations

Last updated