CREATETABLEEXPRESSIONS_TABLE(col VARCHAR(30));CREATEORREPLACEPROCEDURE EXPRESSIONS_SAMPLEISRESULT VARCHAR(50);CONST CONSTANT VARCHAR(20) :='CONSTANT TEXT';BEGIN-- CONSTANT EXPRESSIONS RESULT := CONST;INSERT INTO EXPRESSIONS_TABLE(COL) VALUES (RESULT);END;CALL EXPRESSIONS_SAMPLE();SELECT*FROM EXPRESSIONS_TABLE;
|COL |
|-------------|
|CONSTANT TEXT|
Snowflake
OUT -> Oracle_01.sql
CREATE OR REPLACETABLEEXPRESSIONS_TABLE (col VARCHAR(30))COMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}';CREATEORREPLACEPROCEDURE EXPRESSIONS_SAMPLE ()RETURNSVARCHARLANGUAGESQLCOMMENT ='{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"oracle"}}'EXECUTEASCALLERAS$$DECLARE RESULT VARCHAR(50);--** SSC-FDM-0016 - CONSTANTS ARE NOT SUPPORTED BY SNOWFLAKE SCRIPTING. IT WAS TRANSFORMED TO A VARIABLE ** CONST VARCHAR(20) :='CONSTANT TEXT';BEGIN-- CONSTANT EXPRESSIONS RESULT := :CONST;INSERT INTO EXPRESSIONS_TABLE(COL) VALUES (:RESULT);END;$$;CALL EXPRESSIONS_SAMPLE();SELECT*FROM EXPRESSIONS_TABLE;
|COL |
|-------------|
|CONSTANT TEXT|
Not supported numeric expressions
Oracle
CREATETABLENUMERIC_EXPRESSIONS_TABLE(col number);CREATEORREPLACEPROCEDURE NUMERIC_EXPRESSIONSISRESULT NUMBER;CURSOR C1 ISSELECT*FROM NUMERIC_EXPRESSIONS_TABLE;TYPE NUMERIC_TABLE ISTABLE OF NUMBER(10);COLLECTION NUMERIC_TABLE; BEGIN-- CURSOR EXPRESSIONSOPEN C1; RESULT := C1%ROWCOUNT;CLOSE C1;INSERT INTO NUMERIC_EXPRESSIONS_TABLE(COL) VALUES (RESULT);-- ** OPERATOR RESULT :=10**2;INSERT INTO NUMERIC_EXPRESSIONS_TABLE(COL) VALUES (RESULT);-- COLLECTION EXPRESSIONSCOLLECTION := NUMERIC_TABLE(1, 2, 3, 4, 5, 6); RESULT := COLLECTION.COUNT + COLLECTION.FIRST;INSERT INTO NUMERIC_EXPRESSIONS_TABLE(COL) VALUES (RESULT);-- IMPLICIT CURSOR EXPRESSIONSUPDATE NUMERIC_EXPRESSIONS_TABLE SET COL = COL +4; RESULT :=SQL%ROWCOUNT;INSERT INTO NUMERIC_EXPRESSIONS_TABLE(COL) VALUES (RESULT);END;CALL NUMERIC_EXPRESSIONS();SELECT*FROM NUMERIC_EXPRESSIONS_TABLE;
|COL|
|---|
|4 |
|104|
|11 |
|3 |
Not supported boolean expressions
Oracle
--Aux function to convert BOOLEAN to VARCHARCREATE OR REPLACEFUNCTIONconvert_bool(p1 inBOOLEAN)RETURNVARCHARASvar1 VARCHAR(20) :='FALSE';BEGINIF p1 THENvar1 :='TRUE';ENDIF;RETURN var1;END;--TableCREATETABLEt_boolean_table(conditional_predicate VARCHAR(20),collection_variable VARCHAR(20),sql_variable VARCHAR(20))--Main ProcedureCREATEORREPLACEPROCEDURE p_boolean_limitationsASTYPE varray_example IS VARRAY(4) OF VARCHAR(15);colection_example varray_example := varray_example('John', 'Mary', 'Alberto', 'Juanita');collection_variable BOOLEAN;conditional_predicate BOOLEAN;sql_variable BOOLEAN;--Result variablescol1 VARCHAR(20);col2 VARCHAR(20);col3 VARCHAR(20);BEGIN--Conditional predicateconditional_predicate := INSERTING;--Collection.EXISTS(index)collection_variable := colection_example.EXISTS(2);--Cursor FOUND / NOTFOUND / ISOPENsql_variable:=SQL%FOUND ORSQL%NOTFOUND ORSQL%ISOPEN;--Convert BOOLEAN to VARCHAR to insertcol1 := convert_bool(conditional_predicate);col2 := convert_bool(collection_variable);col3 := convert_bool(sql_variable);INSERT INTO t_boolean_table VALUES (col1, col2, col3);END;CALL p_boolean_limitations();SELECT*FROM t_boolean_table;
Related EWIs.
SSC-FDM-0016: Constants are not supported by Snowflake Scripting. It was transformed to a variable.