Oracle supports User Defined Type (UDT) which include object type and collection. This data type is not supported in SQL Server and SSMA does not support conversion of Oracle UDT. You may consider using SQL Server TVP when migrating your Oracle database to SQL Server.
The following provides use scenarios of UDT and examples on how to recreate the statements in SQL Server:
PL/SQL user defined type is converted to user defined table type
PL/SQL | T-SQL |
CREATE TYPE person_ot AS OBJECT ( firstname VARCHAR(100), lastname VARCHAR(100), hiredate DATE ); | CREATE TYPE person_ot AS TABLE |
CREATE TYPE productcategory_ot AS OBJECT | CREATE TYPE productcategory_ot AS TABLE |
Oracle variable declared as user defined type is converted to sql server variable of user defined table type
PL/SQL | T-SQL |
DECLARE person_var person_ot; | DECLARE @person_var person_ot |
Input argument as user defined type will be converted to sql server table value parameter (TVP)
PL/SQL | T-SQL |
CREATE PROCEDURE showname(person_in IN person_ot, fullname OUT VARCHAR2) | CREATE PROCEDURE showname(@person_in person_ot READONLY, @fullname VARCHAR(200)) |
Output argument as user defined type is converted to retuned data set
PL/SQL | T-SQL |
CREATE OR REPLACE PROCEDURE createperson (firstname IN VARCHAR2, lastname in VARCHAR2, person_out OUT person_ot)
-- sample statement to use the stored procedure | CREATE PROCEDURE createperson (@firstname VARCHAR(100), @lastname VARCHAR(100))
|
Object table is created out of schema definition of the user defined table type
PL/SQL | T-SQL |
CREATE TABLE obtblperson OF person_ot; | DECLARE @person_ot person_ot SELECT * INTO obtblperson FROM @person_ot |
Oracle table column with user defined type is converted into a seperate table. For object type, the main table column is converted into uniqueidentifier column with foreign key relationship to the sub table. For collection, the sub table is created with a foreign key column referring to the primary key of the main table.
PL/SQL | T-SQL |
CREATE TABLE tblemployee_ot | CREATE TABLE tblemployee_ot CREATE TABLE tblemployee_ot$employee ALTER TABLE tblemployee_ot ADD CONSTRAINT fk_employee FOREIGN KEY (employee) REFERENCES t85575343$employee (rowid) |
CREATE TABLE tblemployee_nt ALTER TABLE tblemployee_ot ADD CONSTRAINT fk_employee FOREIGN KEY (employee) REFERENCES t85575343$employee (rowid) | CREATE TABLE tblemployee_nt CREATE TABLE tblemployee_nt$employee |
Member method is converted into procedure or function
PL/SQL | T-SQL |
CREATE OR REPLACE TYPE BODY person_ot -- sample statement using the type member method | ALTER TYPE person_ot ADD MEMBER PROCEDURE update_hiredate (SELF IN OUT NOCOPY person_ot); CREATE PROCEDURE person_ot$proc_update_hiredate (@person_ot person_OT READONLY) -- sample statement to use the stored procedure SELECT 'hiredate: ' + hiredate FROM @person DECLARE @person_ot$proc_update_hiredate person_ot INSERT INTO @person_ot$proc_update_hiredate UPDATE old SET old.hiredate = new.hiredate SELECT 'hiredate: ' + hiredate FROM @person |
Constructor method is converted into procedure
PL/SQL | T-SQL |
CONSTRUCTOR FUNCTION person_ot | CREATE PROCEDURE person_ot$constructor (@firstname VARCHAR(100), @lastname VARCHAR(100)) -- sample statement to use the stored procedure |