This chapter is related to transforming the TYPE attribute when it references a column, variable, record, collection, or cursor. The transformation involves getting the referenced item data type and replacing the referencing item TYPE attribute for the data type obtained.
Sample Source Patterns
TYPE attribute for columns
In this case, the referenced item is a column from a table created previously.
CREATE OR REPLACETABLEtable1 (col1 NUMBER(38, 18) /*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/)COMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}';CREATEORREPLACEPROCEDURE procedure1 ()RETURNSVARCHARLANGUAGESQLCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTEASCALLERAS$$DECLAREvar1 NUMBER(38, 18);BEGINNULL;END;$$;
Further information about NUMBER datatype can be found in Numeric Data Types section.
TYPE attribute for variables
In this case, the referenced item is a variable declared previously.
Further information about FLOAT datatype can be found in FLOAT Data Type section
TYPE attribute for records
In this case, the referenced item is a record declared previously.
Oracle
IN -> Oracle_03.sql
CREATEORREPLACEPROCEDURE procedure1ISTYPE record_typ_def IS RECORD(field1 NUMBER);record_var record_typ_def;var1 record_var%TYPE;var2 record_var.field1%TYPE;BEGINNULL;END;
Snowflake
OUT -> Oracle_03.sql
CREATEORREPLACEPROCEDURE procedure1 ()RETURNSVARCHARLANGUAGESQLCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTEASCALLERAS$$DECLARE!!!RESOLVE EWI!!! /*** SSC-EWI-0056 - CUSTOM TYPES ARE NOT SUPPORTED IN SNOWFLAKE BUT REFERENCES TO THIS CUSTOM TYPE WERE CHANGED TO OBJECT ***/!!!TYPE record_typ_def IS RECORD(field1 NUMBER);record_var OBJECT !!!RESOLVE EWI!!! /*** SSC-EWI-0036 - record_typ_def DATA TYPE CONVERTED TO OBJECT ***/!!! := OBJECT_CONSTRUCT();var1 OBJECT := OBJECT_CONSTRUCT();var2 NUMBER(38, 18);BEGINNULL;END;$$;
In the example before, the variable which is referencing the record variable is changed to OBJECT as same as the record variable, and the variable which is referencing the record field is changed to the record field data type (NUMBER (38, 18)).
In this case, the referenced item is a collection variable, but since collections are not supported, the referencing item TYPE attribute is changed to VARIANT data type.
Oracle
IN -> Oracle_04.sql
CREATEORREPLACEPROCEDURE procedure1ISTYPE collection_type ISTABLE OF NUMBER;collection_var collection_type;var1 collection_var%TYPE;BEGINNULL;END;
Snowflake
OUT -> Oracle_04.sql
CREATEORREPLACEPROCEDURE procedure1 ()RETURNSVARCHARLANGUAGESQLCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTEASCALLERAS$$DECLARE!!!RESOLVE EWI!!! /*** SSC-EWI-0058 - FUNCTIONALITY FOR 'PL COLLECTION TYPE DEFINITION' IS NOT CURRENTLY SUPPORTED BY SNOWFLAKE SCRIPTING ***/!!!TYPE collection_type ISTABLE OF NUMBER;collection_var VARIANT !!!RESOLVE EWI!!! /*** SSC-EWI-0062 - CUSTOM TYPE 'collection_type' USAGE CHANGED TO VARIANT ***/!!!;var1 VARIANT !!!RESOLVE EWI!!! /*** SSC-EWI-OR0129 - TYPE ATTRIBUTE 'collection_var%TYPE' COULD NOT BE RESOLVED, SO IT WAS TRANSFORMED TO VARIANT ***/!!!;BEGINNULL;END;$$;
TYPE attribute for cursors
In this case, the referenced item is a cursor variable, but since REF cursors are not supported, the referencing item TYPE attribute is changed to VARIANT data type.
CREATE OR REPLACETABLEtable1 (col1 NUMBER(38, 18) /*** SSC-FDM-0006 - NUMBER TYPE COLUMN MAY NOT BEHAVE SIMILARLY IN SNOWFLAKE. ***/)COMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}';CREATEORREPLACEPROCEDURE procedure1 ()RETURNSVARCHARLANGUAGESQLCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTEASCALLERAS$$DECLARE----** SSC-FDM-0024 - FUNCTIONALITY FOR 'PL REF CURSOR TYPE DEFINITION' IS NOT CURRENTLY SUPPORTED BY SNOWFLAKE SCRIPTING **--TYPE cursor_type IS REF CURSOR RETURN table1%ROWTYPE;cursor_var_res RESULTSET;var1_res RESULTSET;BEGINNULL;END;$$;
For those cases when the data type of the referenced item cannot be obtained, the referencing item TYPE attribute is changed to VARIANT.
Knows Issues
1. Cursors and collections declarations are not supported.
Collection and cursor variable declarations are not supported yet so the referencing item TYPE attribute is changed to VARIANT and a warning is added in these cases.
2. Original data type could not be obtained.
When the referenced item data type could not be obtained the referencing item TYPE attribute is changed to VARIANT and a warning is added.