Record Type Definition
This is a translation reference to convert the Oracle Record Declaration to Snowflake
This section is a work in progress, information may change in the future.
Description
A record variable is a composite variable whose internal components, called fields, can have different data types. The value of a record variable and the values of its fields can change.
You reference an entire record variable by its name. You reference a record field with the syntax
record.field.You can create a record variable in any of these ways:
Define a record type and then declare a variable of that type.
Use
%ROWTYPEto declare a record variable that represents either a full or partial row of a database table or view.Use
%TYPEto declare a record variable of the same type as a previously declared record variable.
For the translation, the type definition is replaced by an OBJECT Semi-structured Data Type and then its usages are changed accordingly across any operations.
In order to define a Record type, the syntax is as follows:
To declare a variable of this type:
Sample Source Patterns
Record initialization and assignment
This sample attempts to insert two new rows using a record variable which is reassigned mid-procedure.
Oracle
Snowflake
Notice how the reassignments are replaced by an OBJECT_INSERT that updates if the column already exists, and how the VALUES clause is replaced by a SELECT.
%ROWTYPE Record and Values Record
Since the operations are the ones that define the structure, these definitions can be replaced by an OBJECT datatype, but the values of the record need to be decomposed as inserting the record "as-is" is not supported.
Oracle
Snowflake
Please note finally how the OBJECT variable needs to be initialized in order to add the information to it.
Fetching data into a Record
Oracle
Snowflake
Please note the additional OBJECT_CONSTRUCT in the Cursor definition, this is what allows to extract an OBJECT, which then can be used to seamlessly migrate the FETCH statement.
Assigning a Record Variable in a SELECT INTO
This transformation consists in taking advantage of the OBJECT_CONTRUCT function to initialize the record using the SELECT columns as the arguments.
Sample auxiliary code
Oracle
Snowflake
Known Issues
1. The following functionalities are currently not being converted:
Fetching data into a Record.
Nested records (Records inside records).
Collections inside records.
Related EWIs
SSC-EWI-0036: Data type converted to another data type.
SSC-EWI-0056: Create Type Not Supported
SSC-FDM-0006: Number type column may not behave similarly in Snowflake.
SSC-FDM-OR0042: Date Type Transformed To Timestamp Has A Different Behavior.
SSC-FDM-OR0035: DBMS_OUTPUT.PUTLINE check UDF implementation.
SSC-PRF-0003: Fetch inside a loop is considered a complex pattern, this could degrade Snowflake performance.
Last updated
