List of Procedures/Functions in a Package

Hi All,
Is it possible to get List of procedure/functions in a package with their number of lines? I tried querying user_source but it treat package and package as a separate object but not function/procedures in that package.
Thanks.

dbdan wrote:
There are some standards related to Quality Assurance where the quality of product is determined based on the bugs per n number of lines of code. I guess it is 0.01 bug per 1000 lines of code in Six-Sigma (may be not exact). We need to present this to client. My manage want us to get granularity even function/procedures within a package, well that is meaningless, if we can count total lines in a package, but Boss is always right :)What a bunch of baloney. Quality of code is not measured by number of lines but by programming design. And if anything the C language showed that a single line of code can be the most complex part of a program - and more difficult to understand and maintain than 100 "+plain+" lines of code.
Also, what about comments and spacing and formatting? I break down SQL statements in PL/SQL into a properly indented statements that spans multiple lines. So if there are 20 columns to select, there will be 20 lines. Compare this to instead put all 20 columns on a single line.
So using pure line number calculation will make my formatting score a bigger number on the bug chart. Not formatting at all and simply stuffing everything onto a single line (a nice unreadable mess) will be considered to have less bugs!?
So you will need to count statements and not lines. But how accurate is that when some statements are significantly more complex than others? PL/SQL and other languages are not RISC machines where all statements are essentially equal.
Nah.. I think this approach is idiotic, severely flawed, and that your boss is in serious needs of basic education in the principles and fundamentals of software engineering.

Similar Messages

  • How to get a called procedure/function name within package?

    Hi folks,
    is it possible to obtain a called procedure/function name within package?
    For a measuring and tracing purpose, I would like to store an info at the beginning of each procedure/function in package with timestamp + additional details if needed.
    For example:
    CREATE OR REPLACE PACKAGE BODY "TEST_PACKAGE" IS
       PROCEDURE proc_1 IS
       BEGIN
          api_log.trace_data(sysdate, 'START.' || ???????);
          api_log.trace_data(sysdate, 'END.' || ???????);
       END;
       PROCEDURE proc_2 IS
       BEGIN
          api_log.trace_data(sysdate, 'START.' || ???????);
          proc_1;
          api_log.trace_data(sysdate, 'END.' || ???????);
       END;
    END; I would like to replace "???????" with a function which would return a name of called procedure, so result of trace data after calling TEST_PACKAGE.proc_2 would be:
       11.1.2013 09:00:01    START.*TEST_PACKAGE.proc_2*
       11.1.2013 09:00:01    START.*TEST_PACKAGE.proc_1*
       11.1.2013 09:00:01    END.*TEST_PACKAGE.proc_1*
       11.1.2013 09:00:01    END.*TEST_PACKAGE.proc_2*I tried to use "dbms_utility.format_call_stack" but it did not return the name of procedure/function.
    Many thanks,
    Tomas
    PS: I don't want to use an hardcoding

    You've posted enough to know that you need to provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
    >
    is it possible to obtain a called procedure/function name within package?
    For a measuring and tracing purpose, I would like to store an info at the beginning of each procedure/function in package with timestamp + additional details if needed.
    >
    I usually use this method
    1. Create a SQL type for logging information
    2. Put the package name into a constant in the package spec
    3. Add a line to each procedure/function for the name.
    Sample package spec
          * Constants and package variables
              gc_pk_name               CONSTANT VARCHAR2(30) := 'PK_TEST';Sample procedure code in package
          PROCEDURE P_TEST_INIT
          IS
            c_proc_name CONSTANT VARCHAR2(80)  := 'P_TEST_INIT';
            v_log_info  TYPE_LOG_INFO := TYPE_LOG_INFO(gc_pk_name, c_proc_name); -- create the log type instance
          BEGIN
              NULL; -- code goes here
          EXCEPTION
          WHEN ??? THEN
              v_log_info.log_code := SQLCODE;  -- add info to the log type
              v_log_info.log_message := SQLERRM;
              v_log_info.log_time    := SYSDATE;
              pk_log.p_log_error(v_log_info);
                                    raise;
          END P_PK_TEST_INIT;Sample SQL type
    DROP TYPE TYPE_LOG_INFO;
    CREATE OR REPLACE TYPE TYPE_LOG_INFO AUTHID DEFINER AS OBJECT (
    *  NAME:      TYPE_LOG_INFO
    *  PURPOSE:   Holds info used by PK_LOG package to log errors.
    *             Using a TYPE instance keeps the procedures and functions
    *             independent of the logging mechanism.
    *             If new logging features are needed a SUB TYPE can be derived
    *             from this base type to add the new functionality without
    *             breaking any existing code.
    *  REVISIONS:
    *  Ver        Date        Author           Description
    *   1.00      mm/dd/yyyy  me               Initial Version.
        PACKAGE_NAME  VARCHAR2(80),
        PROC_NAME     VARCHAR2(80),
        STEP_NUMBER   NUMBER,
        LOG_LEVEL   VARCHAR2(10),
        LOG_CODE    NUMBER,
        LOG_MESSAGE VARCHAR2(1024),
        LOG_TIME    TIMESTAMP,
        CONSTRUCTOR FUNCTION type_log_info (p_package_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_proc_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_step_number IN NUMBER DEFAULT 1,
                                            p_LOG_level IN VARCHAR2 DEFAULT 'Uninit',
                                            p_LOG_code IN NUMBER DEFAULT -1,
                                            p_LOG_message IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_LOG_time IN DATE DEFAULT SYSDATE)
                    RETURN SELF AS RESULT
      ) NOT FINAL;
    DROP TYPE BODY TYPE_LOG_INFO;
    CREATE OR REPLACE TYPE BODY TYPE_LOG_INFO IS
        CONSTRUCTOR FUNCTION type_log_info (p_package_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_proc_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_step_number IN NUMBER DEFAULT 1,
                                            p_LOG_level IN VARCHAR2 DEFAULT 'Uninit',
                                            p_LOG_code IN NUMBER DEFAULT -1,
                                            p_LOG_message IN VARCHAR2 DEFAULT 'Uninitialized',
                                            p_LOG_time IN DATE DEFAULT SYSDATE)
         RETURN SELF AS RESULT IS
        BEGIN
          self.package_name  := p_package_name;
          self.proc_name     := p_proc_name;
          self.step_number   := p_step_number;
          self.LOG_level   := p_LOG_level;
          self.LOG_code    := p_LOG_code;
          self.LOG_message := p_LOG_message;
          self.LOG_time    := p_LOG_time;
          RETURN;
        END;
    END;
    SHO ERREdited by: rp0428 on Jan 11, 2013 10:35 AM after 1st cup of coffee ;)

  • No procedure/function decomposition in packages in Rel 2

    I noticed that one of the changes since the last release was:
    "View Package Spec and Body - now decompose to display procedures and functions "
    I tried doing this in Rel 2 but there is still no decomposition of procedures/functions.Maybe I have misunderstood what was being said ?
    Also, if you click the package spec, a subfolder labelled "loading..." appears which just stays there ...
    Platform: Xp SP1
    Raptor version:1.0.0.07.96

    Thats a very good point about navigating to the point in a package spec of body where the sub-object resides.
    In cases where packages are thousands of lines long and have numerous procedures/functions, debugging code is difficult if you cant jumpt to points in code that the navigator shows you are there.
    This is one of the few things that plsql navigator does better than Toad in my opinion and I'd happuily use Raptor over both of these if it can emulate what was asked in the last post.
    Am using build 08.97

  • Procedures/functions inside a package

    Hi
    Is there any database table when you can see the procedures/functions ids for each package? I mean a table similar to dba_objects
    thanks

    Did you try
    SQL> desc <package name>

  • DTD verification procedure/function in xmlgen package??

    Is there a function or procedure in xmlgen package that verifies if the xmldocument is compliant with the DTD just like an error is generated if we use Java OracleXML putXML while using Java. Also, I am getting a system class not found (/oracle/rdbms/aurora/compiler) error when loading xmparser.jar file. Should I load the aurora.zip file first using the sys user in C:\oracle\ora81\javavm\lib directory ??

    We can build Java Stored Procedures on Java Classes. If this is your case then the java source will not be visible in the USER_SOURCE view.
    You can see what classes you have loaded in the schema (and whetehr you have the source for them) by running this query (warning: very slow!):
    select name, source
    from USER_JAVA_CLASSES
    /Alternatively you can run this
    select dbms_java.longname(object_name), object_type
    from   user_objects
    where  object_type like 'JAVA%'
    /or join the two together...
    select name, kind, source
    from USER_JAVA_CLASSES
    where name in (  select dbms_java.longname(object_name)
    from   user_objects
    where  object_type = 'JAVA SOURCE')
    /Cheers, APC

  • How to place a procedure/function definition into a package spec.

    How can I declare procedure/function in a package specification so that it has public scope? Presently I am able to create a procedure in a package under sub program units. The problem I am encountering is when I generate the code, the procedure declaration is only ending up in the package body and not the package specification.

    Set the scope property of the procedure to "public" and generate it again...

  • How to modify the Procedure which exists in Package individually?

    Hi,
    I need to modify the procedure which exists in package individually. I.e. I don't want to recompile the entire package.
    This task to be done in SQL Plus not in TOAD. Because in TOAD, we can directly place the script and recompile using the option.
    Do we have any syntax to modify the procedure which exists in package?
    [Like.....     create or replace schema.packagename.procudrename....etc...?]
    Kindly reply if you are not clear on my query.
    Kindly help me on this.

    Explain the reason why this would make any sense. Convenience. I wouldn't mind this option either.
    1) Currently, i am working on a PACKAGE which has
    over 2k lines. In general, changes are made in a
    single PROCEDURE only. I then copy the code (from
    notepad) and paste it into SQL*Plus. This takes a few
    seconds. If i could just ALTER the one PROCEDURE, it
    would save time. (The little adds up to a lot during
    testing.)
    2) If two developers want to modify the two parts of
    the same PACKAGE they would have to rename the
    PACKAGE so one's changes do not overwrite the other.
    Allowing to change the particular PROCEDURE inside
    the PACKAGE would obviate this need.
    3) If PACKAGES are to be stored in a versioning
    system, it might be convenient to store each
    PROCEDURE separately, instead of storing the entire
    PACKAGE as one file.
    It is certainly not required, but it would be a nice
    convenience. That is why it would make sense.OK, then why did you chose to make packages? You do realize you can make stand alone procedures / functions outside of packages don't you?
    I can see how 2 seconds of waiting for a package to compile could set your testing back by weeks (warning, being highly sarcastic).

  • How to find out list of procedures and functions inside a package

    How I can find out the list of Procedures and Functions inside a Package.

    Look at ALL_PROCEDURES and ALL_ARGUMENTS.

  • Sql Developer - View source code of procedures, functions & packages in another schema

    Our developers need the ability to view procedures, function, packages etc. in the production database (using SQL DEVELOPER).  They don't have access to sign on as the owner of these
    objects in Production.  They must use their own limited access UserID for this purpose.
    This limited access UserID has been granted select privilege on DBA_SOURCE & DBA_OBJECTS.  The developers need the ability to view the source of these object via
    the tree view in SQL DEV.  They should be able to click on "other users" in the SQL DEV tree view and see a listing of the owner schema objects.  Then they should
    be able to select the desired object and view the source code.  These developers are used to using GUI interfaces.  Selecting from DBA_SOURCE would not be an
    option for them.
    I understand that if the limited user is granted SELECT ANY DICTIONARY or SELECT_CATALOG_ROLE then this functionality will work.  The problem is those
    privileges/roles  provide much more access than should be granted to these limited access users. Granting DBA to these users is also not an option.
    In TOAD and other end-user tools this functionality works when only select privilege on DBA_SOURCE & DBA_OBJECTS has been granted.  We need this same functionality
    in SQL DEV.
    While searching this forum and the internet, I see that other installations have this same issue.
    Please enhance SQL Developer with this functionality. 
    Thank you, ellen

    Just to double check that I'm interpreting the problem correctly, is the following true:
    select * from all_objects where object_name = 'DBA_SOURCE'
    returns nothing
    select * from dba_source where name = your PL/SQL module
    returns all the code

  • List of procedures in a package

    Hi,
    Iam using oracle 11g.
    is there any option to view list of procedures in a package.
    all_procedures gives me list of procedures defined in package specification.
    But i need list of procedures defined in package body both public and private procedures
    Thanks in advance..
    Edited by: user9080289 on Aug 9, 2010 5:00 AM
    Edited by: user9080289 on Aug 9, 2010 5:00 AM

    try this
    SELECT v.owner,
           (CASE V.type
            WHEN 'FUNCTION'  THEN NULL
            WHEN 'PROCEDURE' THEN NULL
            ELSE v.name
            END
           )PACKAGE_NAME ,
            UPPER(
            SUBSTR
            TRANSLATE(
            LTRIM(REPLACE(SUBSTR(ltrim(v.text),LENGTH('PROCEDURE')+1),'"',''),' '),
            '+++'
            ),---TEXT TO BE SEARCH
            1,---STARTING POSITION
            INSTR(
            TRANSLATE(
            LTRIM(REPLACE(SUBSTR(ltrim(v.text),LENGTH('PROCEDURE')+1),'"',''),' '),
            '+++'
            ||'+'
            '+'
            )-1 ---lENGTH
            )OBJECT_NAME
            TRIM(SUBSTR(ltrim(v.text),1,LENGTH('PROCEDURE')))"TYPE"
    FROM dba_source v
    WHERE (TRIM(ltrim(v.text)) LIKE ('FUNCTION%') OR TRIM(ltrim(v.text)) LIKE ('PROCEDURE%')) AND
          v.owner IN (your schema) AND
          v.type IN ('PACKAGE BODY')
    ORDER BY V.OWNER,V.name,v.text;note:
    you may not need the Translate function here, but in my place the spacing of the procedure is a little bit messy.
    maybe there are other better ways than this
    hope this help
    Edited by: HGDBA on Aug 9, 2010 8:09 AM

  • Call a function inside a package from a stored procedure

    Hello:
    I am kind of new to the stored procedure. Does anyone know how to call a function inside a package from another stored procedure?
    I have a existing function (func_b) inside a package (pack_a) and it returns a cursor. I want to call this function from a stored procedure (proc_c) so that I use the data inside the cursor.
    can I do the following in proc_c:
    my_cursor1 SYS_REFCURSOR;
    begin
    my_cursor1 := exec pack_a.func_b
    end
    It will be very helpful if anyone can point me to any reading or example. Thank you very much for your information.

    guys:
    Thank you for your information so far. I need some more help here. I was able to run the function in my stored procedure. However, I was not able to print the result on the screen to view the cursor result, although I am using dbms_output.put_line statement inside my stored procedure.
    I use the following statement to execute my stored procedure on sql*plus. I can tell the stored procedure is executed successfully, but I did see anything printed:
    DECLARE TEMP VARCHAR2(100);
    BEGIN PROC_LAWS_CAD_NAME_SEARCH('LPD', 'TEST DEVICE ID', 'TEST LAST NAME', 'TEST FIRST NAME', 'F', '11112009', TEMP); END;
    I tried to use 'set serveroutput on' and got the following error:
    ERROR:
    ORA-06502: PL/SQL: numeric or value error: host bind array too small
    ORA-06512: at line 1
    I am kind of confused now. thank you for your help.
    Jack
    Here is my procedure:
    create or replace
    PROCEDURE PROC_SEARCH
    ( AGENCY_ID IN VARCHAR2,
    DEVICE_ID IN VARCHAR2,
    L_NAME IN VARCHAR2,
    F_NAME IN VARCHAR2,
    SEX IN VARCHAR2,
    DOB IN VARCHAR2,
    CAD_NAME_SCH_RESULT_STR OUT VARCHAR2)
    AS
    v_agy_id varchar2(10);
    v_device_id varchar2(20);
    v_l_name varchar2(25);
    v_f_name varchar2(15);
    v_sex varchar2(1);
    v_dob date;
    -- this cursor is going to be used to store a list of warrant matching
    -- name search criteria
    cad_srch_cursor sys_refcursor;
    objSrch SEARCH_RESULT_TEMP%ROWTYPE;
    BEGIN
    cad_srch_cursor := SEARCH_PKG.SEARCH('TESTING', 'TESTER', null, null,null, null, getPhonetic('TESTING'));
    LOOP
    FETCH cad_srch_cursor INTO objSrch;
    EXIT WHEN cad_srch_cursor%NOTFOUND;
    --insert into SEARCH_RESULT_TEMP (name_last) values (objSrch.name_last);
    CAD_NAME_SCH_RESULT_STR := objSrch.name_last;
    dbms_output.put_line('First:'||objSrch.name_first||':Last:'||objSrch.name_last||':Middle:'||objSrch.name_middle);
    end LOOP;
    END PROC_LAWS_SEARCH;
    -----------------------------------------

  • Exp/imp procedures, functions and packages question

    Hi
    I've a 9i R2 version Oracle database. I would like to export procedures, functions and packages from a schema. How do I do that?
    Is there any script or command lines can provide?
    Thanks

    Hello user12259190.
    You can do an export of the user itself, excluding table data as inH:\>exp
    Export: Release 10.2.0.1.0 - Production on Tue Dec 22 11:22:52 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Username: db_user@db_sid
    Password:
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, Data Mining and Real Application Testing options
    Enter array fetch buffer size: 4096 >
    Export file: EXPDAT.DMP >
    (2)U(sers), or (3)T(ables): (2)U > 2
    Export grants (yes/no): yes > no
    Export table data (yes/no): yes > no
    Compress extents (yes/no): yes > no
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    server uses UTF8 character set (possible charset conversion)
    Note: table data (rows) will not be exported
    Note: grants on tables/views/sequences/roles will not be exported
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user DB_USER
    . exporting PUBLIC type synonyms
    . exporting private type synonyms
    . exporting object type definitions for user DB_USER
    About to export DB_USER's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    . about to export DB_USER's tables via Conventional Path ...
    . . exporting table  TABLE_NAMEs
    EXP-00091: Exporting questionable statistics.
    . exporting synonyms
    . exporting views
    . exporting stored procedures
    . exporting operators
    . exporting referential integrity constraints
    . exporting triggers
    . exporting indextypes
    . exporting bitmap, functional and extensible indexes
    . exporting posttables actions
    . exporting materialized views
    . exporting snapshot logs
    . exporting job queues
    . exporting refresh groups and children
    . exporting dimensions
    . exporting post-schema procedural objects and actions
    . exporting statistics
    Export terminated successfully with warnings.Unfortunately, you can't export just the objects you want to unless they are tables.
    Using import (imp) you can list the content of your packages, procedures, functions, views, etc. and perhaps that will give you what you need.
    Another choice would be to useSELECT * FROM user_source ORDER BY 2, 1, 3;to list the code.
    Hope this helps,
    Luke

  • How to obtain the list of procedures and functions

    hi,
    how can I obtain the list of all the stored procedure & functions in the database?

    SELECT * FROM DBA_OBJECTS WHERE OBJECT_TYPE IN ('FUNCTION','PROCEDURE')
    Cheers

  • SQL query statement  for stored procedure / function listing ...

    Hi everyone,
    Is there a SQL query to list all the stored procedures and functions of an user in an Oracle 8 database?
    I have this idea:
    select * from USER_SOURCE where TYPE = 'PROCEDURE' or TYPE = 'FUNCTION'
    but I am not too sure whether this is correct.
    Thanks in advance,
    Eric

    Yeah
    I agree with you Garcia , my above posting was a correction to the query mentioned in the question only.
    you are correct
    If you only want the name of the object,
    SELECT Object_Name from User_Objects where object_type in ( 'PROCEDURE' ,'FUNCTION');
    is much faster than Selecting (distinct) from User_Source.

  • Encryption of pl/sql package/procedures/function code

    Is it possible to make the code inside a package/procedure/function un readable to other users.
    As is some of the api package body code in portal ?
    thanks in anticipation.
    SD,

    PL/SQL Wrap Utilityhttp://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/c_wrap.htm#LNPLS016
    Note, however that you cannot revert back to original un-wrapped code from a code that has been wrapped. You would need access to the original source files to get the original source code.

Maybe you are looking for

  • Can't read jpgs from macbook pro and iphoto on my pc

    help.... in my iphoto library i highlighted the pictures i wanted to export.... i hit file, export, chose jpg, chose the folder to drop them in and hit ok...... everything seemed ok, but when I connected the external hard drive to my pc I could not v

  • Photo Booth Audio and Video not in sync!

    I am a YouTube musician. When I go to record I find it easiest to use the video feature in Photo Booth. However, ever since I upgraded to Mountain Lion my audio and video in my videos has been off of one another. They start off together but by the en

  • "#NAME?" showing up instead of values...NEED HELP!

    Gurus, I need to write BPC reports to a network folder by the entity so that anyone who is not BPC user  can access it. Is it possible? I have set up a book with the entity being varkey. The reports publish alright but if BPC is not running on users'

  • PO release strategy ONLY for change

    I have a requirement to only have a release strategy for a purchase order only when it is changed The problem is that even if I can disable the event to be triggered when created, the release strategy is written down to the EKKO-table when the PO is

  • Wireless playing music on MacBook Pro via LaCie Fuel

    I bought a LaCie Fuel 1 TB (wireless external hard drive) for my ipad. But since it's not that cheap. I want to use it for my macbook pro as well. I transferred the whole Itunes folder (incl library etc) to the hard drive. I put the music back in the