Programmatically modify package body source

Hi,
I need to write a java programm or a script that will allow me to programmatically modify the sources of all packages from several schemas.
We need to do something similar to a search/replace in the source code of the package bodies from several schemas. Is there a way to do that ? Where should I modify the code ?
Thank you.
p.s. I can connect as sys.

In PL/SQL, you can use the dbms_metadata package to get the ddl to replace the package, transform it with regexp_translate or your own procedure (substr, instr, ...), then execute.
Regards
Laurent

Similar Messages

  • Package Body in the tree doesn't show all procedures

    I am using Sql Developer 1.0.0.14.67 on Win XP Professional,
    DB servers Oracle 9i on both Linux Red HAt and Win XP Professional
    I have troubles with one of packages - in the tree under Package Body SQL Developer doesn't show all procedures of this package body.
    On the right panel all package body source is shown, but in the tree under Package Body it shows names of only procedures up to certain line in the source code - up to line where first Private (not included in Package Spec) procedure code starts.
    BUT, there are more Public procedures in package body below this Private procedure - and all of procedures below first private are not included in the tree under Package Body

    I find this quite annoying. I cannot use the navigation panel on the left to find the location of all functions and procedures in the package body. The 'missing' procedures are listed under the package spec, and double clicking on them takes me to the spec and not the body.
    I'm running v1.2.1.32.13. Is this a know issue and is there a fix planned?

  • Modifying ALDSP data source end points programmatically

    I can see how to manually modify ALDSP data source end points through the ldconsole:
    http://edocs.bea.com/aldsp/docs21/admin/server.html#1042064
    but is there any programmatic way to do this?
    For my purpose, it would be adequate if there were some Ant tasks to do the job (e.g. like using the "wlconfig" task to tweak JMX attributes).
    Thanks,
    Mark

    You can modify the settings in <adminserverhome>/liquiddata/<yourApp>LDConfig.xml
    The settings are read from the file when the application is deployed

  • Problem in package body creation

    Hello,
    I am a newbie in PL/SQL.I am sorry for posting a very silly question,but I am struggling since 2 days trying to get this PL/SQL code working.Dont know whats wrong with it.I consulated a lot of tutorials and online sources..But still couldnt figure out whats wrong.I get the following error
    LINE/COL ERROR
    6/1 PLS-00103: Encountered the symbol "CREATE"
    The code is like following
    CREATE or replace package test AS
         procedure extract_tmp_reifs ;
    end;
    CREATE OR REPLACE PACKAGE BODY test IS procedure extract_info(models IN varchar2,rulebases IN varchar2) is
    stmt varchar2(4000);
    model_name varchar2(4000);
    rulebase_name varchar2(4000);
         --Create table invocation
    begin     
         model_name := models;
         rulebase_name := rulebases;
         stmt := 'create table '|| model_name ||'_'||rulebase_name||'_t$'||'(id number primary key, triple_id number, sd date, ed date)';
         execute immediate stmt;
         commit;     
    end extract_tmp_reifs;     
    end temporal_reification;
    The line 6 is for the Create package body thing.
    WIll be grateful if some one can give a hint as to whats wrong wiith it.Please help me
    Thanks
    Regards
    Prateek!

    > The requirement is to have a procedure which when provided two parameters
    creates a table based on the parameters,and then values are inserted into the
    table by using data from other tables.Thats why the dynamic creation of table.
    I still don't like it. Besides the dynamic create issue, there is a relational design issue at stake here.
    Attribute data is to be carried in the columns of a table - and not in the table name. The correct relation (from the little code I've seen posted here) is:
    Model Rules = ( Model ID, Rulebase ID, Tripple ID, Start Date, End Date)
    And not multiple relations where the relational table's name is dynamic and the attribute data carried in the name of the table. To put it into context, it is the same as defining an Invoice Relation as:
    Invoices_20070305 = ( Invoice ID, Customer ID, Product ID, Quantity, Unit Cost, ..etc.. )
    Instead of putting the date as an attribute value into the relation:
    Invoices = ( Invoice ID, Invoice Date, Customer ID, Product ID, Quantity, Unit Cost, ..etc.. )
    Using this dynamic method you can wind up with 1000's of tables for Model Rules. How are you going to make use of referential integrity? What about indexing? What about the complexity of having all these many dynamic tables and attempting to query them with a single query?
    99% of the time, dynamically creating relations (tables) in a RDBMS is the wrong thing to do. And unless you can convince me that you have the 1% exception to the rule, I'm going to be very skeptical about the dynamic table create approach you have chosen. It is simply wrong.

  • Sql developer hangs when saving pl/sql external package or package body fil

    When I open a package body file I can modify the contents of the file.
    Compilation of the file works fine but when I want to close or save the file SQL developer hangs. I use version 1.2 (previous version did have the same problem.)
    Somebody has an idee what I'am doing wrong?

    Are you using 1.2.1.32.13?
    Sue

  • "Read Only" open other schema's package body even have write permission

    Oracle SQL Developer 2.1 (2.1.0.63)
    I can view and modify package under my schema, but when I open other schema's package body, it show "Read Only" in status bar and can't type in code editor.
    I'm sure my connected user have write permission and it works fine in old sql developer version.
    Is there some toggle for "read only" view or some issue for new release?

    Not very helpful for you at the moment, but according to EA 2.1. Can't edit another users store procedures. this has been bugged and will hopefully get fixed soon.
    theFurryOne

  • DBMS_METADATA Package Body won't compile

    I get a PLS-00103 error when attempting to complile the package body for SYS.DBMS_METADATA. The body hasn't been modified so I'm not sure where to look.

    Or,
    Does anyone know where in a script I can find the line that created this package and body in the first place?

  • Search Package Body for Keywords

    I would like to know if anyone has a query to search a package body for a particular word and then return all of the procedure names where that word (or words) are found. I am in the beginning stages of a 3-5 year upgrade/re-write project and just when I think that I have been given all of the requirements "they" come up with something else. Go figure! For instance I might need to find all of the procedures for a package or packages that contain the word product. Manually searching through all of my packages is very time consuming and I'm sure that someone out there has already written a query to do this.
    Any help will be greatly appreciated!
    Thanks!
    Randy

    >
    I would like to know if anyone has a query to search a package body for a particular word and then return all of the procedure names where that word (or words) are found. I am in the beginning stages of a 3-5 year upgrade/re-write project and just when I think that I have been given all of the requirements "they" come up with something else. Go figure! For instance I might need to find all of the procedures for a package or packages that contain the word product. Manually searching through all of my packages is very time consuming and I'm sure that someone out there has already written a query to do this.
    >
    A query? No
    Would you settle for Oracle supplied functionality that can probably provide all of that cross-reference information for you?
    As you can tell from all of the other replies it seems many, if not most, people are not familiar with PL/Scope, which was introduced in version 11.1 (you should always provide your 4 digit Oracle version).
    >
    PL/Scope is a compiler-driven tool that collects data about identifiers in PL/SQL source code at program-unit compilation time and makes it available in static data dictionary views. The collected data includes information about identifier types, usages (declaration, definition, reference, call, assigment) and the location of each usage in the source code.
    PL/Scope enables the development of powerful and effective PL/Scope source code browsers that increase PL/SQL developer productivity by minimizing time spent browsing and understanding source code.
    PL/Scope is intended for application developers, and will usually be used in the environment of a development database.
    >
    See Chapter 8 Using PL/Scope in the Advanced Appication Developer's Guide
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_plscope.htm
    >
    Specifying Identifier Collection
    By default, PL/Scope does not collect data for identifiers in the PL/SQL source program. To have PL/Scope collect data for all identifiers in the PL/SQL source program, including identifiers in package bodies, set the PL/SQL compilation parameter PLSCOPE_SETTINGS to 'IDENTIFIERS:ALL'.
    >
    Without knowing your actual needs or requirements I can't speculate on whether this will give you everything you are looking for.
    But don't reinvent the wheel without checking this out first.
    Basically just set the compilation parameter and recompile all of the code. Then there will be static dictionary views available with the cross-reference data.
    Even if you are not currently using 11g if I were you I would create an 11g sandbox with all of the objects and code (no data needed) just so you could use PL/Scope to get this cross-reference information.

  • How can i find start line of any functions or procedures stored in package body?

    hi
    how can i find start line of any functions or procedures stored in package body?
    is there any way to write a query from for example user_source?
    thanks

    how can i find start line of any functions or procedures stored in package body?
    Why? What will you do differently if a procedure starts on line 173 instead of line 254?
    Tell us what PROBLEM you are trying to solve so we can help you find the best way to solve it.
    If you use PL_SCOPE that info is available in the *_IDENTIFIERS views. See 'Using PL/Scope in the Advanced Dev Doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_plscope.htm
    Try this simple sample code. The query is modified from that doc sample:
    -- tell the compiler to collect the info
    ALTER SESSION SET PLSCOPE_SETTINGS='IDENTIFIERS:ALL';
    -- recompile the package
    CREATE OR REPLACE package SCOTT.pack1 as
    PROCEDURE proc1;
    PROCEDURE proc2;
    END;
    CREATE OR REPLACE package BODY SCOTT.pack1 as
    PROCEDURE proc1 IS
    BEGIN
      NULL;
    END;
    PROCEDURE proc2 IS
    BEGIN
      proc1;
    END;
    PROCEDURE proc3 IS
    BEGIN
      proc1;
      proc2;
    END;
    END;
    -- query the info for the package spec
    WITH v AS (
      SELECT    Line,
                Col,
                INITCAP(NAME) Name,
                LOWER(TYPE)   Type,
                LOWER(USAGE)  Usage,
                USAGE_ID,
                USAGE_CONTEXT_ID
        FROM USER_IDENTIFIERS
          WHERE Object_Name = 'PACK1'
            AND Object_Type = 'PACKAGE'
    SELECT LINE, RPAD(LPAD(' ', 2*(Level-1)) ||
                     Name, 20, '.')||' '||
                     RPAD(Type, 20)||
                     RPAD(Usage, 20)
                     IDENTIFIER_USAGE_CONTEXTS
      FROM v
      START WITH USAGE_CONTEXT_ID = 0
      CONNECT BY PRIOR USAGE_ID = USAGE_CONTEXT_ID
      ORDER SIBLINGS BY Line, Col
    LINE,IDENTIFIER_USAGE_CONTEXTS
    1,Pack1............... package             declaration        
    2,  Proc1............. procedure           declaration        
    3,  Proc2............. procedure           declaration        
    -- query the info for the package body - change 'PACKAGE' to 'PACKAGE BODY' in the query above
    LINE,IDENTIFIER_USAGE_CONTEXTS
    1,Pack1............... package             definition         
    2,  Proc1............. procedure           definition         
    6,  Proc2............. procedure           definition         
    8,    Proc1........... procedure           call               
    10,  Proc3............. procedure           declaration        
    10,    Proc3........... procedure           definition         
    12,      Proc1......... procedure           call               
    13,      Proc2......... procedure           call               

  • SQL*Developer 3EA1 - Not Compiling package Body

    Don't know if this is best place to post this, if not tell me where.
    In some packages i'm getting: Error: ORA-06550: linha 1, coluna 64:PLS-00172: literal de cadeia de caracteres demasiado extenso; Sorry about the portuguese error message but it's cpopy paste from compiler log.
    The strange about this is that the package is compiling with no errors on Version 2.1.1.64 and also on others editors. In both packages i had this was after formatting the code.
    So far is the only bug i got, keep on the good work.
    António Cunha

    Just tried from pl/sql node. The package body does not compile from there either. The issue seems to be the size of the package. The package size is 35,000 characters and spaces. I can remove any combination of source lines to get it down to 32,000 characters and spaces and it will compile.
    Edited by: dagtech on Oct 21, 2010 9:34 AM

  • VIew of Package body in another schema in EA 3.0

    I would like the ability in SQL Developer to view the package body of another schema with the CREATE ANY PRIVILGE.
    For instance, in TOAD you can grant access to DBA_SOURCE or SELECT_CATALOG_ROLE and then be able to view another schema's package body.
    This is long overdue without having to log into that schema or granting CREATE ANY PRIVILEDGE to user.
    This one is really needed

    "CREATE ANY PRIVILEGE" is irrelevant to the ability of viewing the source owned by other users.
    Please provide exact script for creating a user, which is able to see the code, say in HR schema, via the query
    select * from all_source
    where owner = 'HR'
    and yet missing the nodes in the OtherUsers->Packages->PKG_A->PKG_A Body in the navigator.

  • Are PL/SQL Package Body Constants in Shared Area or Private Area

    Based on this it not clear to me if PL/SQL Package Body Constants are stored in shared area or private area.
    http://docs.oracle.com/cd/B28359_01/server.111/b28318/memory.htm
    "PL/SQL Program Units and the Shared Pool
    Oracle Database processes PL/SQL program units (procedures, functions, packages, anonymous blocks, and database triggers) much the same way it processes individual SQL statements. Oracle Database allocates a shared area to hold the parsed, compiled form of a program unit. Oracle Database allocates a private area to hold values specific to the session that runs the program unit, including local, global, and package variables (also known as package instantiation) and buffers for executing SQL. If more than one user runs the same program unit, then a single, shared area is used by all users, while each user maintains a separate copy of his or her private SQL area, holding values specific to his or her session.
    Individual SQL statements contained within a PL/SQL program unit are processed as described in the previous sections. Despite their origins within a PL/SQL program unit, these SQL statements use a shared area to hold their parsed representations and a private area for each session that runs the statement."
    I am also curious what are the fine grained differences from a memory and performance perspective (multi-session) for the two examples below. Is one more efficient?
    Example 1.
    create or replace
    package body
    application_util
    as
    c_create_metadata constant varchar2(6000) := ...
    procedure process_xxx
    as
    begin
    end process_xxx;
    end application_util;
    vs.
    Example 2.
    create or replace
    package body
    application_util
    as
    procedure process_xxx
    as
    c_create_metadata constant varchar2(6000) := ...
    begin
    end process_xxx;
    end application_util;

    >
    What i am asking is fairly granular, so here it is again, let's assume latest version of oracle..
    In a general sense, is the runtime process able to manage memory more effectively in either case, one even slightly more performant, etc
    ie does example 1 have different memory management characteristics than example 2.
    Specifically i am talking about the memory allocation and unallocation for the constant varchar2(6000)
    Ok, a compiler's purpose is basically to create an optimized execution path from source code.
    The constant varchar2(6000) := would exist somewhere in the parse tree/execution path (this is stored in the shared area?).
    I guess among the things i'm after is
    1) does each session use space needed for an additional varchar2(6000) or does runtime processor simply point to the constant string in the parse tree (compiled form which is shared).
    2) if each session requires allocation of space needed for an additional varchar2(6000), then for example 1 and example 2
    at what point does the constant varchar allocation take place and when is the memory unallocated.
    Basically does defining the constant within the procedure have different memory characteristics than defining the constant at the package body level?
    >
    Each 'block' or 'subprogram' has a different scope. So the 'constant' defined in your example1 is 'different' (and has a different scope) than the 'constant' defined in example2.
    Those are two DIFFERENT objects. The value of the 'constant' is NOT assigned until control passes to that block.
    See the PL/SQL Language doc
    http://docs.oracle.com/cd/E14072_01/appdev.112/e10472/fundamentals.htm#BEIJHGDF
    >
    Initial Values of Variables and Constants
    In a variable declaration, the initial value is optional (the default is NULL). In a constant declaration, the initial value is required (and the constant can never have a different value).
    The initial value is assigned to the variable or constant every time control passes to the block or subprogram that contains the declaration. If the declaration is in a package specification, the initial value is assigned to the variable or constant once for each session (whether the variable or constant is public or private).
    >
    Perhaps this example code will show you why, especially for the second example, a 'constant' is not necessarily CONSTANT. ;)
    Here is the package spec and body
    create or replace package pk_test as
      spec_user varchar2(6000);
      spec_constant varchar2(6000) := 'dummy constant';
      spec_constant1 constant varchar2(6000) := 'first constant';
      spec_constant2 constant varchar2(6000) := 'this is the second constant';
      spec_constant3 constant varchar2(6000) := spec_constant;
      procedure process_xxx;
      procedure change_constant;
    end pk_test;
    create or replace package body pk_test as
    procedure process_xxx
    as
      c_create_metadata constant varchar2(6000) := spec_constant;
    begin
      dbms_output.put_line('constant value is [' || c_create_metadata || '].');
    end process_xxx;
    procedure change_constant
    as
    begin
      spec_constant := spec_constant2;
    end change_constant;
    begin
      dbms_output.enable;
      select user into spec_user from dual;
      spec_constant := 'User is ' || spec_user || '.';
    end pk_test;The package init code sets the value of a packge variable (that is NOT a constant) based on the session USER (last code line in package body).
    The 'process_xxx' procedure gets the value of it's 'constant from that 'non constant' package variable.
      c_create_metadata constant varchar2(6000) := spec_constant;The 'change_constant' procedure changes the value of the package variable used as the source of the 'process_xxx' constant.
    Now the fun part.
    execute the 'process_xxx' procedure as user SCOTT.
    SQL> exec pk_test.process_xxx;
    constant value is [User is SCOTT.].Now execute 'process_xxx' as another user
    SQL> exec pk_test.process_xxx;
    constant value is [User is HR.].Now exec the 'change_constant' procedure.
    Now exec the 'process_xxx' procedure as user SCOTT again.
    SQL> exec pk_test.process_xxx;
    constant value is [this is the second constant].That 'constant' defined in the 'process_xxx' procedure IS NOT CONSTANT; it now has a DIFFERENT VALUE.
    If you exec the procedure as user HR it will still show the HR constant value.
    That should convince you that each session has its own set of 'constant' values and so does each block.
    Actually the bigger memory issue is the one you didn't ask about: varchar2(6000)
    Because you declared that using a value of 6,000 (which is 2 ,000 or more) the actual memory allocation not done until RUN TIME and will only use the actual amount of memory needed.
    That is, it WILL NOT pre-allocate 6000 bytes. See the same doc
    http://docs.oracle.com/cd/E14072_01/appdev.112/e10472/datatypes.htm#CJAEDAEA
    >
    Memory Allocation for Character Variables
    For a CHAR variable, or for a VARCHAR2 variable whose maximum size is less than 2,000 bytes, PL/SQL allocates enough memory for the maximum size at compile time. For a VARCHAR2 whose maximum size is 2,000 bytes or more, PL/SQL allocates enough memory to store the actual value at run time. In this way, PL/SQL optimizes smaller VARCHAR2 variables for performance and larger ones for efficient memory use.
    For example, if you assign the same 500-byte value to VARCHAR2(1999 BYTE) and VARCHAR2(2000 BYTE) variables, PL/SQL allocates 1999 bytes for the former variable at compile time and 500 bytes for the latter variable at run time.
    >
    So when you have variables and don't know how much space is really needed do NOT do this:
    myVar1 VARCHAR2(1000);
    myVar2 VARCHAR2(1000);
    myVar3 VARCHAR2(1000);The above WILL allocate 3000 bytes of expensive memory even if it those variables are NEVER used.
    This may look worse but, as the doc states, it won't really allocate anything if those variables are not used. And when they are used it will only use what is needed.
    myVar1 VARCHAR2(2000);
    myVar2 VARCHAR2(2000);
    myVar3 VARCHAR2(2000);

  • Getting the error pop up ORA-04063: package body "APPS.PA_FAXFACE"

    Hi All,
    When I try to open the 'Capital Projects' screen (Capitalization -> Capital Projects) I get an error pop up with the error message "ORA-04063: package body "APPS.PA_FAXFACE"". I choose to close the error pop up, it shows me the Capital Projects window where I tried to search for my capital project. Just when I hit the Find button it throws me away and closes my forms session.
    I checked the status of the package PA_FAXFACE which was INVALID (obviously, because it says the package has errors). I tried to recompile the package body with alter package command but that failed and it didn't show any error messages.
    So, I understand that there are some errors in the package PA_FAXFACE. I am not sure why the errors are there and what might have caused the errors.
    Any pointers to resolve the above issue or any light towards resolving the issue would be of great help.
    Thanks in Advance !!
    Lalitha.

    Tom,
    modified the file $APPL_TOP/admin/adconfig.txt
    replace the old node to new node in this file and run adautocfg.shAre you referring to APPL_TOP_NAME?
    but after successful autoconfig and check the name in adconfig.txt it changed back the really old name.
    Please advise where it picked up that name from.From the context file, so verify all parameters in the application context file which still points to the old server and replace it with the new one then run AutoConfig again. For APPL_TOP_NAME, it is "<APPL_TOP_NAME oa_var="s_atName">NODE NAME</APPL_TOP_NAME>".
    Regards,
    Hussein

  • Privilege to view package body

    Hi all,
    I have two users... user 'A' and user 'B' (real user names changed to protect the innocent). User A creates a package spec and package body.
    I want user B to be able to see the code in the package body that user A owns. Ideally I would like user B to be able to view the body code in TOAD via the schema browser or via a DESC. Is this possible?
    Thanks,
    Scott
    PS user B can see the package spec just fine...

    Having the execute privilege on a package should not give anyone the ability to see the source for the package body in all_source and if definitely does not give the user the ability to change the package. The privilege only allows them to execute the package.
    By default only the owner and DBA privileged users can read both the package specification and the body from all_source. Having execute privilege will allow a user to read the specification.
    One way to provide access is to create your own version of the all_source views and grant this to whoever needs the access. You can either write a very specific tailored view for the one user or create a user security table that you use to control who can see what via this special view. Plus you have to grant select access to the special view before anyone can use it.
    HTH -- Mark D Powell --

  • Mapping deploy : ORA 06550 PACKAGE BODY... 101031:insufficient privileges

    Hi All,
    I am using OWB11.2,
    When i deploying a very simply mapping.
    i met the following error
    ORA 06550 PACKAGE BODY line 15 column 13: PL/SQL: 101031:insufficient privileges
    ORA 06550 PACKAGE BODY line 11, column 2: PL/SQL: SQL statement ignored
    i have grant source's 'select' privilege to target schema
    i have add the target schema to owb user group and from 'security' i tick all privllege to target schema
    don't know what else privilege do i need to add to target schema.
    Thanks for you attention.

    Hi,
    if your error statement is
    FROM
    "SCHEMA_SOURCE"."TABLE_NAME_SOURCE" "ALIAS"
    then you need direct grant on object "TABLE_NAME_SOURCE" from "SCHEMA_SOURCE"-user to target user (package owner).
    GRANT SELECT /* ALL */ ON "SCHEMA_SOURCE"."TABLE_NAME_SOURCE" TO package_owner.
    Best Regards,
    IM
    Edited by: user9014055 on 21.02.2012 06:26

Maybe you are looking for

  • How to display the subtotals (BPC NW 7.5)

    We are on BPC-NW 7.5 I have to develop a schedule where I have to show totals at each parent node based on what they enter for the base members. (Is it possible to show totals before they save, as they enter data?) If my dimension is as below Parent1

  • Charging a MacBook Pro (60 MagSafe) with an Air (45w MagSafe) plug.

    Can I safely charge a MacBook Pro (60 MagSafe) with a MacBook Air wall charger (45w MagSafe)?  I ask because I'm replacing a 2009 MacBook Pro with a new Air and the Pro cord is dead. I'd like to charge the pro with the air charger so I can transfer f

  • Any Flash gallery plugin for LR like Flickr..

    Hi I am trying to find out if there is any Flash gallery plugin similar to how Flickr displays Album. Presently I use LR Flash web gallery. But I like the way Flickr shows the images. I want to use the gallery in my own web site. Thanks Chandra

  • Migrating cluster to new hardware

    Does anyone know of any best practices/documentation on migrating an existing RAC cluster to new hardware and operating system? We do not use ASM, but OCFS2. Thanks!

  • Media Encoder 2014.1 Will Not Que

    Since the recent update to Media Encoder 2014.1 and Yosemite media encoder will not render premiere sequences.  Here's what I'm doing. Opening Media Encoder Add Premiere Pro Sequence Click Render ... Nothing happens, it gives me the option to stop, b