Collections & Records

This section is focused in the transformation of composite data types: Collections and Records.

Some parts in the output code are omitted for clarity reasons.

Records

You might also be interested in Records declaration.

Oracle

IN -> Oracle_01.sql
CREATE OR REPLACE PROCEDURE RECORDS_PROC AS 
 TYPE DEPTRECTYP IS RECORD (
    DEPT_ID    NUMBER(4) NOT NULL := 10,
    DEPT_NAME  VARCHAR2(30) NOT NULL := 'ADMINISTRATION',
    MGR_ID     NUMBER(6) := 200,
    LOC_ID     NUMBER(4) := 1700
  );
  
  TYPE NAME_REC IS RECORD (
    FIRST  EMPLOYEES.FIRST_NAME%TYPE,
    LAST   EMPLOYEES.LAST_NAME%TYPE
  );
 
  TYPE CONTACT IS RECORD (
    NAME  NAME_REC,-- NESTED RECORD
    PHONE EMPLOYEES.PHONE_NUMBER%TYPE
  );
 
  DEPT1 DEPTRECTYP;
  DEPT_NAME DEPTRECTYP;
  C1 CONTACT;
BEGIN
  DEPT1.DEPT_NAME := 'PURCHASING';
  C1.NAME.FIRST := 'FALVARADO';
  C1.PHONE := '50687818481';
  SELECT * INTO DEPT1 FROM FTABLE46;
  INSERT INTO TABLA1 VALUES (DEPT1.DEPT_NAME);
  INSERT INTO TABLA1 VALUES (DEPT_NAME.DEPT_NAME);
  EXECUTE IMMEDIATE 'SELECT * FROM FTABLE46' INTO DEPT_NAME;
END;

Snowflake

Transformation for "SELECT INTO Record" is in progress.

OUT -> Oracle_01.sql
CREATE OR REPLACE PROCEDURE RECORDS_PROC ()
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"oracle"}}'
EXECUTE AS CALLER
AS
$$
 DECLARE
  !!!RESOLVE EWI!!! /*** SSC-EWI-0056 - CUSTOM TYPES ARE NOT SUPPORTED IN SNOWFLAKE BUT REFERENCES TO THIS CUSTOM TYPE WERE CHANGED TO OBJECT ***/!!!
  TYPE DEPTRECTYP IS RECORD (
     DEPT_ID    NUMBER(4) NOT NULL := 10,
     DEPT_NAME  VARCHAR2(30) NOT NULL := 'ADMINISTRATION',
     MGR_ID     NUMBER(6) := 200,
     LOC_ID     NUMBER(4) := 1700
   );
  !!!RESOLVE EWI!!! /*** SSC-EWI-0056 - CUSTOM TYPES ARE NOT SUPPORTED IN SNOWFLAKE BUT REFERENCES TO THIS CUSTOM TYPE WERE CHANGED TO OBJECT ***/!!!

   TYPE NAME_REC IS RECORD (
     FIRST  EMPLOYEES.FIRST_NAME%TYPE,
     LAST   EMPLOYEES.LAST_NAME%TYPE
   );
  !!!RESOLVE EWI!!! /*** SSC-EWI-0056 - CUSTOM TYPES ARE NOT SUPPORTED IN SNOWFLAKE BUT REFERENCES TO THIS CUSTOM TYPE WERE CHANGED TO OBJECT ***/!!!

   TYPE CONTACT IS RECORD (
     NAME  NAME_REC,-- NESTED RECORD
     PHONE EMPLOYEES.PHONE_NUMBER%TYPE
   );

   DEPT1 OBJECT !!!RESOLVE EWI!!! /*** SSC-EWI-0036 - DEPTRECTYP DATA TYPE CONVERTED TO OBJECT ***/!!! := OBJECT_CONSTRUCT();
   DEPT_NAME OBJECT !!!RESOLVE EWI!!! /*** SSC-EWI-0036 - DEPTRECTYP DATA TYPE CONVERTED TO OBJECT ***/!!! := OBJECT_CONSTRUCT();
   C1 OBJECT !!!RESOLVE EWI!!! /*** SSC-EWI-0036 - CONTACT DATA TYPE CONVERTED TO OBJECT ***/!!! := OBJECT_CONSTRUCT();
 BEGIN
  DEPT1 := OBJECT_INSERT(DEPT1, 'DEPT_NAME', 'PURCHASING', true);
  C1 := OBJECT_INSERT(C1, 'FIRST', 'FALVARADO', true);
  C1 := OBJECT_INSERT(C1, 'PHONE', '50687818481', true);
  SELECT
   OBJECT_CONSTRUCT( *) INTO
   :DEPT1
  FROM
   FTABLE46;
  INSERT INTO TABLA1
  SELECT
   :DEPT1.DEPT_NAME:DEPT_ID,
   :DEPT1.DEPT_NAME:DEPT_NAME,
   :DEPT1.DEPT_NAME:MGR_ID,
   :DEPT1.DEPT_NAME:LOC_ID;
  INSERT INTO TABLA1
  SELECT
   :DEPT_NAME.DEPT_NAME:DEPT_ID,
   :DEPT_NAME.DEPT_NAME:DEPT_NAME,
   :DEPT_NAME.DEPT_NAME:MGR_ID,
   :DEPT_NAME.DEPT_NAME:LOC_ID;
  !!!RESOLVE EWI!!! /*** SSC-EWI-0030 - THE STATEMENT BELOW HAS USAGES OF DYNAMIC SQL. ***/!!!
  EXECUTE IMMEDIATE 'SELECT * FROM
   FTABLE46'
            !!!RESOLVE EWI!!! /*** SSC-EWI-0058 - FUNCTIONALITY FOR 'EXECUTE IMMEDIATE RETURNING CLAUSE' IS NOT CURRENTLY SUPPORTED BY SNOWFLAKE SCRIPTING ***/!!!
            INTO DEPT_NAME;
 END;
$$;

Known Issues

No issues were found.

  1. SSC-EWI-0036: Data type converted to another data type.

  2. SSC-EWI-0056: Create Type Not Supported.

  3. SSC-EWI-0058: Functionality is not currently supported by Snowflake Scripting.

  4. SSC-EWI-0030: The statement below has usages of dynamic SQL

Last updated