Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check a type's dependents order to drop them and replace/modify the initial type?

I tried to modify a type using the following code and it gave me the error code: 'ORA-02303'. I don't know much about Oracle or PL/SQL but I need to solve this; so I'd appreciate any further help with this.

Thanks in advance. The code is just an example. But then again, I need to check its dependents first.

create or replace type A as object (
  x_ number, 
  y_ varchar2(10),
  member procedure to_upper
);
/
like image 805
reefaktor Avatar asked Apr 12 '10 19:04

reefaktor


People also ask

How do I fix error ORA 00955?

Resolving The Problem If you have created a database object such as a table, view, index, or synonym that already exists you will receive this error. The database objects must have distinct names. You need to have a unique name for the database object or modify or drop the existing object so it can be reused.

How do you drop the bass and dependent objects in Oracle?

How do you drop the bass and dependent objects in Oracle? You can use the FORCE option to drop the type even if it has dependent database objects. When you use the force drop type syntax, Oracle marks as unused all columns dependent on the type to be dropped, and those columns become inaccessible.

How do you drop a record type in SQL?

Use the DROP TYPE statement to drop the specification and body of an object type, a varray, or a nested table type.

Can we alter type in Oracle?

Use the ALTER TYPE statement to add or drop member attributes or methods. You can change the existing properties ( FINAL or INSTANTIABLE ) of an object type, and you can modify the scalar attributes of the type.


2 Answers

Look in DBA_DEPENDENCIES, ALL_DEPENDENCIES, or USER_DEPENDENCIES as appropriate:

SELECT OWNER, NAME, TYPE
  FROM DBA_DEPENDENCIES 
 WHERE REFERENCED_OWNER = [type owner]
   AND REFERENCED_NAME  = [type name]
   AND REFERENCED_TYPE  = 'TYPE'
/
like image 130
Adam Musch Avatar answered Oct 13 '22 22:10

Adam Musch


Do not use DROP with FORCE, as it will automatically modify tables (delete columns) and god know what else to validate everything. Use something like:

ALTER TYPE type_name DROP ATTRIBUTE attr_name INVALIDATE;
ALTER TYPE type_name ADD ATTRIBUTE attr_name varchar2(50) CASCADE;

This will work on types with table/type dependencies.

like image 30
Charles Henry Avatar answered Oct 13 '22 22:10

Charles Henry