How to create a global type of Oracle and use it in PL / SQL?

Oracle RECORD TYPE declared in a procedure or function is local, so it can only be used locally. How to declare a RECORD TYPE that is global and can be used in all procedures and functions globally in the database?

+4
source share
2 answers

Record types cannot be created as a separate object of the circuit, therefore for public access of the Record type the type is usually declared in the package specification or the body of the package is available only in the volume of this package,

+5
source

A basic example of using an object type in your package.

 CREATE OR REPLACE TYPE test_rec IS OBJECT ( ID VARCHAR2(30) ,TYPE VARCHAR2(30) ); / CREATE OR REPLACE TYPE test_NT AS TABLE OF test_rec; / declare v_test_NT test_NT; begin select test_rec (id ,type ) BULK COLLECT INTO v_test_NT FROM test ; --use it as you want end; 
+3
source

Source: https://habr.com/ru/post/1438379/


All Articles