Some parts in the output code are omitted for clarity reasons.
Description
This custom UDF is added to avoid runtime exceptions caused by format differences when casting strings to DATE, inside procedures and functions.
Custom UDF overloads
CAST_DATE_UDF(datestr)
It creates a DATE from a STRING.
Parameters
DATESTR: A STRING that represents a DATE with a specific format.
CREATE OR REPLACE FUNCTION PUBLIC.CAST_DATE_UDF(DATESTR STRING) RETURNS DATELANGUAGE SQLIMMUTABLECOMMENT='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"udf"}}'AS$$SELECTTO_DATE(DATESTR,'YYYY-MM-DD"T"HH24:MI:SS.FF')$$;
Oracle
IN -> Oracle_01.sql
--Create TableCREATETABLEjsdateudf_table( col1 DATE );--Create ProcedureCREATEORREPLACEPROCEDURE jsdateudf_proc ( par1 DATE )ISBEGININSERT INTO jsdateudf_table VALUES(par1);END;--Insert DateCALL jsdateudf_proc('20-03-1996');--SelectSELECT*FROM jsdateudf_table;
Take into consideration that Oracle DATE contains an empty TIMESTAMP (00:00:00.000), while Snowflake DATE does not. SnowConvert allows transforming DATE to TIMESTAMP with the flag.