简体   繁体   中英

Error PLS-00201 while trying to create table type in Oracle

When I run this code in Oracle 19c:

CREATE TYPE t_my_type IS TABLE OF my_table.my_col%TYPE;

I have this error:

Type t_my_type compiled

LINE/COL  ERROR
--------- -------------------------------------------------------------
0/0       PL/SQL: Compilation unit analysis terminated
1/23      PLS-00201: identifier 'my_table.my_col' must be declared
Errors: check compiler log

Why does it says that it must be declared?

Found answer here: https://community.oracle.com/tech/developers/discussion/3582858/pls-00201-when-declaring-table-type

You can't use %TYPE in this case. You must use some predefined Oracle type like NUMBER or create a collection.

Example:

CREATE TYPE t_my_type IS TABLE OF NUMBER;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM