code for collection in package

Posted on 2011-05-05
Last Modified: 2013-12-07
what is the code for finding all collections in a package
Question by:thota198
    LVL 76

    Expert Comment

    by:slightwv (䄆 Netminder)
    What are you asking?  Are you wanting to loop through an entire package and look for all Pl/SQL tables and/or VArrays declared in it?
    LVL 14

    Expert Comment

    Your question is ambiguous.  Please let us know if you are finding trouble in existing code or you want to develop NEW code in PL/SQL

    Author Comment

    i was trying to finding out how many collections are there in the package so wht is the code for it
    LVL 14

    Expert Comment

    You have to manually count the collections in a package specs or body

    Collections can be of:
    LVL 76

    Accepted Solution

    Assuming the package isn't wrapped, you might be able to write some code that goes through dba_source looking for terms such as 'TABLE OF' and 'VARRAY'.  I'm not sure I would trust it to be 100% accurate but it might be close enough for what you are wanting.

    This can get easier in 11g with REGEXP_COUNT.

    Something like:

          select 'TABLE OF', count(*) from dba_source where name='MY_PKG' and type = 'PACKAGE BODY' and owner='SCOTT' and upper(text) like '%TABLE OF%';

    quick regex:
          select 'TABLE OF', count(*) from dba_source where name='MY_PKG' and type = 'PACKAGE BODY' and owner='SCOTT' and regexp_like(text,'TABLE OF','i');

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Tracking a Database Lock - SQL 2014 10 30
    Access Join Query 12 35
    oracle query help 36 45
    Pfile and SPfile - Oracle 2 21
    How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now