Skip to Main Content

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Munesh.

Asked: July 11, 2017 - 4:32 pm UTC

Last updated: July 12, 2017 - 2:12 pm UTC

Version: 11g R2

Viewed 1000+ times

You Asked

Hi TOM,
I want to write an extract utility, which will get data from selected columns of multiple tables so planning to use pipeline function which will return a ORACLE TYPE.

To create type, I would like give reference of column type from source table as below -

CREATE OR REPLACE TYPE mytype AS OBJECT (
  COL1  SOURCETAB1.COL1%TYPE,
  COL2 SOURCETAB2.COL2%TYPE,
  COL3 SOURCETAB3.COL3%TYPE
);


But this throws an error and does not allow to create this type. I do not want to give hardcode datatype in this object to avoid maintains issue.

Please suggest on this. thanks.

and Chris said...

Unfortunately not. The data types in objects have to be:

This data type must be stored in the database; that is, either a predefined data type or a user-defined standalone collection type

http://docs.oracle.com/database/121/LNPLS/create_type.htm#LNPLS01375

You can find the PL/SQL data types at:

http://docs.oracle.com/database/121/LNPLS/datatypes.htm#LNPLS003

And the collection types at:

http://docs.oracle.com/database/121/LNPLS/composites.htm#LNPLS00501

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library