Extracting package and procedure name in code

In my exception processing I need to log the package and procedure name that got the exception. How do I obtain these two names without manually coding the names?
Thanks in anticipiation

A better option is to get the package name and the line numberA still better option is to utilize pl/scope (when you are in 11g (not sure about 10g)):
SQL> alter session set plscope_settings='identifiers:all'
Session altered.
SQL> set serverout on
SQL> create or replace package pkg
as
   procedure p1;
   procedure p2;
end pkg;
Package created.
SQL> create or replace package body pkg
as
   procedure get_scope (obj varchar2, line int)
   as
   begin
      for c in (select rpad (lpad (' ', 2 * (level - 1)) || name, 20, '.') || ' ' || rpad (type, 20) || rpad (usage, 20) identifier_usage_contexts
                from user_identifiers t
                where level != 1
                start with line = get_scope.line and object_name = obj
                connect by usage_id = prior usage_context_id)
      loop
         dbms_output.put_line (c.identifier_usage_contexts);
      end loop;
   end get_scope;
   procedure p1
   as
   begin
      null;
   end p1;
   procedure p2
   as
   begin
      get_scope ($$plsql_unit, $$plsql_line);
   end p2;
end pkg;
Package body created.
SQL> exec pkg.p2
  P2................ PROCEDURE           DEFINITION         
    PKG............. PACKAGE             DEFINITION         
    PKG............. PACKAGE             DECLARATION        
PL/SQL procedure successfully completed.

Similar Messages

  • SubVersion in SQL Developer - how to link to packages and procedures

    My question is this - I am starting out using SubVersion in Oracle and it seems pretty straightforward to use as a source control for files that are stored in a Windows directory, that is the only way I have used it so far.
    Am I able to use it to control packages and procedures that I have saved as part of my database, ie the procedures are part of a package and the package appears within the Packages section of the appropriate connection in SQL Developer.
    I hope this makes sense.
    Cheers,
    JabJam

    Hi JabJam,
    So far, everyone is correct. SQL Developer just uses a file-based source control system (e.g., SVN), which means updating database object definitions via scripts under version control, or somehow exporting the new definition to a script so it can be version controlled after the fact. And wouldn't it be nice if the database objects could be version controlled directly. With the database developer having control over when any changes are committed for shared use in the database. Similar to using the SVN plug-in for an IDE like Eclipse for a given programming language in a shared development environment.
    But what would your DBA have to say about that? Don't most DBAs require scripts for deploying code or structural changes?
    In Oracle, definitions (DDL) are committed automatically. Anyone granted access sees them. Since you probably don't do development directly against a production database, eventually scripts (either manual or generated) will be needed for deployment to QA or production. Few mechanisms currently exist to work against an active database without other authorized users also seeing these changes.
    For DDL, the closest thing would be the fairly recent edition-based redefinition feature in 11g (R2, I think). For DML, the OWM (Oracle Workspace Management) feature would be loosely analogous.
    This is not a simple issue. Version control via an extension for Subversion provides essential basic support. Going beyond that might mean watching the evolution of edition-based redefinition, but DBAs would probably require scripts for that too.
    Regards,
    Gary
    SQL Developer Team

  • Sql developer doesn't show any packages and procedure.

    Hi All,
    I am perty new here and I am facing a strange problem in SQL DEVELOPER. I have one schema and it has packages and functions created in it, but when I click
    packages or functions in sql developer it says table or views does not exist. however, I can see those packages and procedures from sql plus and oracle enterprise manager. you swift reply would be highly appriciated
    hare krishna
    Alok

    Which version of sqldeveloper?
    Which version of Oracle?
    This sounds like an old bug where sqldeveloper checked for 'select any table', but you actually need 'select any dictionary'

  • [svn] 2932: Updated manifests with recent changes to TCAL package and class names.

    Revision: 2932
    Author: [email protected]
    Date: 2008-08-20 14:01:37 -0700 (Wed, 20 Aug 2008)
    Log Message:
    Updated manifests with recent changes to TCAL package and class names.
    Reviewer: Jason
    Bugs: SDK-16531
    QA: No
    Doc: No
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-16531
    Modified Paths:
    flex/sdk/trunk/frameworks/fxg-manifest.xml
    flex/sdk/trunk/frameworks/mxml-2009-manifest.xml

    Revision: 2932
    Author: [email protected]
    Date: 2008-08-20 14:01:37 -0700 (Wed, 20 Aug 2008)
    Log Message:
    Updated manifests with recent changes to TCAL package and class names.
    Reviewer: Jason
    Bugs: SDK-16531
    QA: No
    Doc: No
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-16531
    Modified Paths:
    flex/sdk/trunk/frameworks/fxg-manifest.xml
    flex/sdk/trunk/frameworks/mxml-2009-manifest.xml

  • Why apps don't need to be granted for synonyms of packages and procedures?

    Normally, When a user create a synonym of other schemas' package or procedure, it requires to be authorized to execute via 'grant' by owner before the user can call it.
    But on one of our environment of EBS 12.1.1(vis), apps user don't need to be granted. Just need to make synonym and then can call the synonym. while on another environment of EBS 12.1.1(product), it still need to be granted. I notice that apps user in the two diffierent environment has many different database roles. Is any role associated with this? Does anybody know the reason?
    Thanks in advance!
    Jing
    Edited by: user12954958 on Aug 25, 2010 11:44 PM

    Hi Jing;
    Please check below thread which is posted Hussein Sawwan
    Re: apps & applsys password
    aaps,applsyspub,applsys
    Re: apps & applsys password
    Regard
    Helios

  • Accessing package and procedure using dblink

    How can I access my package and function using a dblink.
    my query is like this
    select id from tablel(pck_prod.fetchid('p107'))
    union select pck_prod.pid('p107') from dual
    my package pck_prod is on remote machine and I have dblink to that machine.
    fetchid and pid are my functions in the package.
    Thanks

    Does it look anything like this?
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> CREATE OR REPLACE TYPE varchar2_table AS
      2     TABLE OF VARCHAR2 (4000);
      3  /
    Type created.
    SQL> CREATE OR REPLACE FUNCTION function_name
      2     RETURN varchar2_table
      3  IS
      4  BEGIN
      5     RETURN varchar2_table ('Banana');
      6  END;
      7  /
    Function created.
    SQL> SELECT column_value
      2  FROM   TABLE (function_name);
    COLUMN_VALUE
    Banana
    SQL> CREATE DATABASE LINK scott
      2     CONNECT TO scott
      3     IDENTIFIED BY tiger
      4     USING 'XE';
    Database link created.
    SQL> SELECT column_value
      2  FROM   TABLE (function_name@scott);
    SELECT column_value
    ERROR at line 1:
    ORA-30626: function/procedure parameters of remote object types are not
    supported
    SQL> If so then the key phrase here is 'remote object types'.

  • Double quotes in function and procedure names when using impdp

    When viewing a function in the original database, it looks like:
    CREATE OR REPLACE FUNCTION TA_ACTIVITY_D_GEN_FNC
    After doing an expdp and impdp to restore a development database, it now looks like
    CREATE OR REPLACE FUNCTION "TA_ACTIVITY_D_GEN_FNC"
    and also has 2 blank lines at end of function.
    This causes us problems when trying to use various utilites to compare differences in production and development. Now every function and procedure shows up as being different.
    Can someone please explain why and what can be done to avoid this from happening?
    Edited by: user6116705 on Jun 15, 2010 7:52 AM

    from old exp, here is the first line of the create procedure statement:
    CREATE FORMAT71 PROCEDURE "SECURE_DML"
    You can see the double quotes. I don't understand why you wouldn't see the same compare issue with old exp. I was wondering what you were using for compare since it would let me know where to look for anything that has changed from the original create to the create performed by data pump. I remember there being an issue in this area. I just don't remember if it was extra spacing, upcasing, or something else or multiple changes. You could contact Oracle support to see if there is a fix and if it is backported to your version.
    The only other way you can possibly fix this (and it would be a huge pain) would be to run impdp with a sqlfile and then edit the sqfile to remove the double quotes and to remove any extra spacing/extra lines. A patch from Oracle would certainly be easier if one was available.
    Dean

  • Package -  using procedure names and variables

    I know that having created a package I can call the procedures using the form PACKAGE_NAME.PROCEDURE_NAME --
    However, for speed and clarity of code is there a way to 'open' the package once and then simply refer to the PROCEDURE_NAME ???
    This would be a sort of temporary synonym.
    Thanks

    You do not need to refer to qualify a procedure with the package name within the package, otherwise you must use the full package.prodedure name. So if package :pkg1 contains procedures A & B, then A can simply refer to B and vice versa, but from another package you would have to call pkg1.B.

  • Error message when compiling invalid packages and procedures

    Hi.
    I have a routine for copying certain data from a production database to a test database. To do this I disable constraints and triggers, truncate tables, copy tables and enable triggers and constraints again.
    Now several of my functions, procedures and packages are made invalid and marked with a red cross. In SQL Developer I can compile invalid functions, procedures and packages. When I compile functions it works fine, but when compiling procedures and packages I get the following error message:
    An error was encountered performing the requested operation:
    ORA-00904: "ATTRIBUTE": Invalid identifier
    Vendor code 904
    When I click OK on this message I get a confirmation saying:
    Packages have been compiled with #0.CNT# errors.
    I had this error in both the previous and the new version. Is this a bug or is there a way to come around it? When I copy and modify the SQL generated to perform this task and run it in SQL Plus it works fine.
    I use Windows 2000 5.00.2195 Service Pack 4, SQL Developer version 1.2.1, Oracle 9.2.0.8.0 and Java version 1.5.0_11
    Message was edited by:
    SvSig

    i have now upgraded to Java 1.6 update 2. I still get basically the same error, but it is presented a little bit differently:
    An error was encountered performing the requested operation:
    ORA-00904: "ATTRIBUTE": invalid identifier
    00904. 00000 - "%s: invalid identifier"
    *Cause:
    *Action:
    Vendor code 904
    Are there other possible error causes than the operating system version and the database version?
    We are going to install an Oracle 10 test database in a couple of weeks, so then I will find out whether the database version is the problem.

  • Download package and program name and owner to excel

    Hi,all:
        I have a question: can i download programs' name  and owners in a specific package to a excel or word file?
    thanks in advance  and best regards
    kevin.

    Kevin,
    As Gautam mentioned you need to gather the data from TADIR table into internal table and call GU_DOWNLOAD fm to download internal table data into excel sheet
    Thanks
    Bala Duvvuri

  • Get top packages and procedures

    What is the best way to get a count of how many times all functions, procedures or packages are running in a database which has no documentation? Would this require a re-coding of all current objects (there are several thousand)?
    Any advice is much appreciated.

    One way would be to turn on auditing for the packages/procedures in question. You could then query dba_audit_trail to see who, what, and when are calling them. Keep in mind that this can have performance impacts.

  • Granting view/select access to packages and procedures

    We have role that we grant to users allowing them select access to tables, views, etc.
    They also need to be able to view the contents of packages, etc.
    Does anyone no a way of granting them access (other than grant execute) so they can only view the content of a package?

    It is not normal for users to be granted access to the source code. Even if you have EXECUTE on another user's package you can only read the spec, not the body.
    If you want to do this then you will need to build some filtering views over the _SOURCE view and grant SELECT on the new views to the users in question.
    A much better solution would be to just allow people to look at the source in the source control repository.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Toad packages and procedures not staying compiled

    Dear All,
    I am using Toad 9.6, and i am suffering a problem. when my server restart then my some of procedure or function not staying compiled. Even all procedure are compile correctly. Because of this problem , my application generating error.
    We haven't seen any pattern as to which ones become uncompiled. One day i compile all my procedure successfully and the next morning the some of procedures are uncompiled. Most of the time they will work after being
    recompiled, but occasionally they will stay compiled for a few minutes and then go back to being uncompiled.
    any help?
    Regards,

    Thanks alot for reply
    If i run this then never compiled object come uncompiled...
    Regards,

  • FULL caller name (package AND  proc)

    I don't know any way to detect caller's package and procedure name. DBMS_UTILITY.format_call_stack is not in effect. Is it correct?

    It is a shame, and apparently it isn't resolved in 10g either. It would make things like error and exception logging much slicker, and it's quite frustrating because you can see all of the details in the error stack. Hmmmm!

  • Find all Package and their related Procedure Names using a specifc Table

    I have 25 Packages
    Each Package holds 30-35 Procedures
    I need to find out all Packages and Procedures
    Each Procedure handles 5 - 20 Tables as Per The Need of Business Rule.
    I need All Package and Related Procedure Names Where a Specific Table Name Appears(DBA_SOURCE doesn't serve purpose.)
    Early Reply Appreciated.
    Thanks and Regards,

    I tried the solution provided to me, but unfortunately the issue remains the same.
    I was Advised to Execute the SQL utldtree.Sql, and then Execute deptree_fill.
    The output is given by a Table DEPTREE (Columns are: .'NESTED_LEVEL', 'TYPE', 'SCHEMA', 'NAME' and 'SEQ#')
    The output I am getting From the Table DEPTREE is as follows -
    Column TYPE value is PACKAGE; Column NAME Value is ACTUAL PACKAGE NAME
    Column TYPE value is PACKAGE BODY; Column NAME Value is ACTUAL PACKAGE NAME
    This repeats till the count the TABLE Name is found in the same PACKAGE
    Desired Output should be -
    Column TYPE value PACKAGE; Column NAME Value ACTUAL PACKAGE NAME
    Column TYPE value PACKAGE BODY; Column NAME Value ACTUAL PACKAGE BODY NAME
    This should repeat till the count the TABLE Name appears in different PACKAGE BODY of the same PACKAGE
    Warm Regards,

Maybe you are looking for

  • Speed up operation of write to file VI

    I have a daq situation where an analog input is wired to my PC. I have a labview circuit which has the daq assistant connected to the "Enable" input of the "write to file" VI. The "elapsed time" vi is connected to the signal input. When the input sig

  • Best setting for 1080i HD

    I've been looking around on the web for a while now looking for the best solution to output my project for HD.  I create commercials for a local TV station and we just started broadcasting HD commercials.  What is the best setting to use when renderi

  • Leading zeroes when loading data

    Hi , I have infobject 0gl_account being used in production . I am now using it in a custom ods also. however , when i load data into the ods , GL account field gets loaded with leading zeroes. when i load master data to 0gl_account, there are no lead

  • Shape Layers: Undefined is not an object

    I've used rd_GimmePropPath to get the Match Names for shape properties but I get an "undefined is not an object" error using the following: app.project.item(1).layer("Shape").("ADBE Root Vectors Group")("ADBE Vector Shape - Ellipse")("ADBE Vector Ell

  • Update labview 2010 to 2013

    Can i update my labview 2010 to 2013????? How ? plz help me. . .  i need to install Electrical power suite 2013/2012  . it requires 2013/2012 version of labview . .i have labview 2010 installed on my PC . Please help me . How can i update my Labview