Compiling Procedures/Packages/Functions

I'm fairly new to the arena of compiling Procedures/Packages/Funcitons but I was given the task of updating a development DB with a lot of newly created/updated Objects. I have created a shell script to go through all the new files and create or replace all the new objects in sqlplus. My question is how to compile all the newly created objects and their dependencies correctly? I have been using SQL Developer to verify that everything has compiled but I see that some are marked invalid which I assume is because a dependency was compiled after it. What would be my best way to making sure everything is valid? I hope this makes sense but any help would be appreciated.

You can use a script like this to build your own sql statement to compile the invalid objects. You can add your own statement for other object types at the end with a union, ie TYPE body.
You will probably need to run it repeated until all objects are VALID. You can put it in a PL/SQL block with a loop and execute immediate so reduce the manual work.
--PACKAGE
select 'alter package ' || object_name || ' compile;' from user_objects
WHERE Status = 'INVALID'
and object_type= 'PACKAGE'
union
-- PACKAGE BODY
select 'alter package ' || object_name || ' compile body;' from user_objects
WHERE Status = 'INVALID'
and object_type= 'PACKAGE BODY'
union
--PROCEDURE
select 'alter procedure ' || object_name || ' compile;' from user_objects
WHERE Status = 'INVALID'
and object_type= 'PROCEDURE'
union
--FUNCTION
select 'alter function ' || object_name || ' compile;' from user_objects
WHERE Status = 'INVALID'
and object_type= 'FUNCTION'
union
--TRIGGER
select 'alter trigger ' || object_name || ' compile;' from user_objects
WHERE Status = 'INVALID'
and object_type= 'TRIGGER'
union
--VIEW
select 'alter view ' || object_name || ' compile;' from user_objects
WHERE Status = 'INVALID'
and object_type= 'VIEW'

Similar Messages

  • Can we Rollback Procedure, Package, function?

    Hi
    All,
    I have compiled Procedure, Package and Function and I realize that those were wrong version. How can I revert Back?
    Thanks,
    Vishal

    Possible options :-
    1. load the old package using a script (this is why we have change control / code control processes).
    or if you don't have the script you could :-
    2. depending on your database version you may be able to use flashback query to select from dba_source (I have not tested this)
    3. restore the database to another location (you probably only need the SYSTEM tablespace) and extract the code from dba_source

  • How to check if column_ name is used by any procedure ,package ,function

    Hello
    Help Is greatly appreciated .
    Kindly please let me know for the folllwoing:
    How to check if column_ name is used by any procedure ,package ,function ,trigger or in any dataabse objects

    >
    How to check if column_ name is used by any procedure ,package ,function ,trigger or in any dataabse objects
    >
    In general you can't. Code can always exist outside the database and it is always possible that you have dynamic code and there is no way to find references like that if used by dynamic code. That dynamic code reference could be based on a query stored in a table.
    And there is no way of knowing if external code (e.g. a Java app) references that column.
    Another issue is that a column could exist in multiple schemas and in multiple objects of different types in those schemas. So a global DB search for 'MY_COLUMN' might turn up references in multiple schemas and you may only care about one schema.
    Unfortunately a reference to 'MY_COLUMN' in code could refer to many different objects or to an object in different schemas so how would you resolve those? Especially if you take synonyms into account which can ponit about anywhere.
    Why don't you tell us what it is you are really trying to do?
    Are you trying to find the references to a particular column? Why? Are you planning on removing/renaming the column? If so then the simplest way is to remove/rename the column and see what objects become invalid. Those invalid objects will have become invalid because that column is no longer available.
    As suggested you can use DBA_SOURCE for references in code that use the standard names. But for tables/views you need to use all_tab_columns. And for dynamic code or client code (e.g. a Java application) there is no way.

  • In RAC Unable To Access -Procedures, Packages, Functions

    We are setting up our 1st RAC. We normally use AllAround's PL/SQL developer but I'm experimenting with this Oracle Product. One problem is that when I attempt to expand Procedures, Packages or Functions ( click on '+' ) I get an ORA-00942 error (table does not exist - Vendor Code 942). I have no problem getting there with the AllAround's PL/SQL developer.
    Any guidance or thoughts will be appreciated.
    Thanks
    Dave

    There is a current bug where if you have 'select any table' privilege, sqldeveloper assumes you can see the DBA_* views, but you actually need select catalag for that.
    The workaround is either revoke select any table or grant select catalog

  • 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.

  • How to use type, packages, functions, and procedures in another schema ?

    I have two target schema in one OWB project, such as A and B. In a mapping of A, I would like to use some types, packages, functions, and procedures from B. I have tried the method of synonym as suggested, but I could not find the metadata of these when importing ... The only type of synonym I can import is the synonym for table. Is there a bug for synonym?
    If I cannot use synonym for this issue, is there another way to solve the problem?

    Now, in some instances you will absolutely need to create the second module as Carsten describes, however it should also be noted that you can reference objects in things like Expressions even if you have not loaded up the metadata. It is only when you need strong binding that it becomes neccessary to import objects. For everything else, as long as the reference will resolve at compile-time then you are good to go.
    For example, I have a function in one target schema (S1) and a private synonym to it in another(s2). A mapping in the S2 schema has an expression object that uses the synonym to the function in the expression property for a couple of the output attirbutes. The synonym has not been loaded into metadata - indeed OWB has no knowledge of its existance. But it resolves at compile time so the mapping validates and generates successfully.
    Mike

  • Datatype of parameters defined in PLSQL function and procedures (packages)

    Hi,
    Require help with this one.
    We have written a unit test generator given a PLSQL package name (and several other unit test attributes). This it does by looking at metadata from user_arguments.
    We have hit upon a issue with %ROWTYPE parameters.
    It apparently splits such arguments into data_level = 0 (the actual ROWTYPE parameter) and data_level = 1 (the individual components of the ROWTYPE) in user_arguments table.
    From the data_level = 0 row, i am unable to retrieve the name of the table of which the ROWTYPE is hinged to.
    I am looking for this information to be able to declare a variable, initialize it and pass it over to the package.function / procedure being tested.
    Is there a way i can retrieve this information (what's the table name its %ROWTYPE of) ?
    Thanks,
    Krishnan

    We have written a unit test generator given a PLSQL package name (and several other unit test attributes)Nice.
    Is there a way i can retrieve this information (what's the table name its %ROWTYPE of) ?Unfortunately not that I know of, the underlying anchored datatype is not recorded in USER_ARGUMENTS or the underlying SYS.ARGUMENT$.
    Assuming such types were declared at package specification it would be theoretically possible to do this lookup by exploiting the DIANA interface (DIUTIL, DIANA and PIDL packages) but that would be a significant undertaking. Alternatively I suppose you could consider parsing the source code but this again would be a significant undertaking and would not support wrapped code.
    The good news is that the compiler does not require that an identically anchored record is passed to the function/procedure, rather the declaration of the attributes of the record must match. In which case you can (simplistically) just declare a local record type with the argument_name, data_type, data_precision, data_scale and/or data_length from USER_ARGUMENTS level 1 then declare a variable of that type and pass it to the function/procedure under test. I say simplistically because there is (albeit rather rarely used) support for nested record types in PL/SQL, hence levels > 1 may exist in USER_ARGUMENTS.
    Edited by: padderz on 30-Mar-2011 02:27

  • Packaged function not compiling

    This one is driving me mad as I cannot see any possible
    reason for it.
    I have two packages containing functions. They are both owned by one schema, different to the schema I am using to build my form. They are both granted execute to public and have public synonyms which are the same as the package name.
    The schema I am using to build my form can access the functions in sqlplus by specifying package.function.
    In my form I have:
    variable1 := package1.function1;
    variable2 := package2.function2;
    The first line compiles OK. The second comes up with function2 must be declared. If I prefix it with owner. it is OK.
    I cannot find any difference between the packages to explain this behaviour. Any ideas anyone please.

    Steve
    I had discussed it with someone else. He claimed afterwards that he had thought of that solution but it was so obvious he didn't like to insult me by suggesting it. I don't know if I believe him.
    Pavel
    Nice idea but we have too much code to retrospectively tidy up. Also with changes of personnel over the years we have such a mixture of different naming conventions that they are pretty meaningless. However, I do prefix my pll procedures with lib to give a clue where to look for them.

  • 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.

  • How to know (package , procedures or functions) name for current sessions

    Hi all
    I'm DBA and i want to find way to get object name whatever (package , procedures or functions) for current running statement in active session.
    To clarify when i open session browser from toad i can see active sessions and see current statement for every session but without the name of the object.
    Is there any way to know this point.
    thanks in advance

    select *
      from dba_objects
    where object_id in (select nvl(t.PLSQL_ENTRY_OBJECT_ID,-1)
                           from v$session t
                          where sid = 452)
    Ramin Hashimzade

  • Re-compiling a package in a stored procedure

    Hi All,
    We are using Oracle 10g. I have coded a stored procedure that does many things one of which is re-creating a Materialized View using Dynamic SQL. However, when this Materialized View is created, a package that this stored procedure needs, becomes invalid. What is the syntax for recompiling the package using Dynamic SQL? I tried something like script listed below, but I am getting "*ORA-24344: success with compilation error*" error message. I like to re-compile the package before it's use in this stored procedure.
    DECLARE
          v_sql         VARCHAR2 (1000);
          object_name   VARCHAR2 (50) := 'TEST.PS2_FNS366';
    BEGIN
           dbms_output.put_line('This is a test.');
           v_sql := 'Alter package ' || object_name || ' compile  package';
           dbms_output.put_line (v_sql);
           EXECUTE IMMEDIATE v_sql;
           v_sql := 'Alter package ' || object_name || ' compile  body';
           dbms_output.put_line (v_sql);
           EXECUTE IMMEDIATE v_sql;     
    END;Thanks,
    Seyed

    Hi Justin,
    I agree with you. Initially, I didn't want to use materialized view in the stored procedure to load a table, but I a kind of was forced into it. I first tried using an Oracle View, but then the Oracle package using it was not finding the view. Then I tried to grant select to it, that failed too. That is when I decided to use a materialized view because, at least I could issue the needed grants.
    After seeing your e-mail and Frank's, I went back to my original plan. I re-created the old view and then tried to give it the right grants. Here is what I tried and the resulting error message:
    GRANT SELECT ON STUDENT.v_ben_reg_case_number TO SCOTT A grant similar to above results in ORA-01720: grant option does not exit for one of the underlying tables. Our DBA tried granting a developer role a system privilege called under_any_role, but that didn't solve it either.
    Thank you for your assistance,
    Seyed

  • Can i create any procedure or function inside a oracle reserve package?

    Hi!
    Can i create any procedure or function inside a oracle reserve package. Suppose, I want to create a function called x in the dbms_output package. Can i do that? Or can i extend the features of this package and create/derived a function from it like we extend any class in JAVA. I'm not sure - whether this is at all possible. I'll be waiting for your reply.
    Thanks in advance.
    Satyaki De.

    No, but you can write a wrapper package and use that instead of using the Built-In package directly. So, instead of calling DBMS_OUTPUT, you call your own Package.
    Steven Feuerstein wrote a wrapper for DBMS_OUTPUT, called P:
    Re: DBMS_OUTPUT.PUT_LINE

  • Diff between function,procedure/packages  and Diff bet delete,truncate,drop

    Dear all
    I am your pal ranga from IT capital bangalore india. I would like have detail discussion with respect to subject. Pls discuss
    Thanks and Regards
    B.Rangarajan

    Justin gave good advise but here is the short version of the answer just for the heck of it
    Function => stored code suitable for use in the select list of a query and in the where clause conditions that generally accepts one parameter and returns one value. Allows user to extend list of Oracle provided row queries.
    Procedure => stored code designed to return one or more values to the caller. Procedures are generally called from other stored code routines or directly from the user application and not as part of a query or DML statement.
    Package => a collection of stored procedures and functions
    Delete => DML row operation to remove rows from a table
    Truncate => DDL operation to quicky and with minimum overhead mark a table and its associated indexes as empty
    Drop => DDL operation to remove a table or other object from the database
    Maybe these definitions will help until you cover the reading. You can also learn this from the Concepts manual. If you are a DBA this manual is where you should start. For a Developer I would start with the Application Developers - Fundamentals.
    HTH -- Mark D Powell --

  • Can i compile new procedures/packages on my snapshot standby?

    Hi
    can i compile new procedures/packages on my snapshot standby?
    I need to test the new release of the application, which include some changes to current packages
    thanks

    yes you can do it, just that it will be flashbed back to the restore point when it was standby first, do anything on it, but be aware that later you convert from snapshot standby to physical standby, more time it would take for redo to be applied and also it is mandatory to open the snapshot at least once in read-write mode before it can be converted into a physical standby database.
    Regards
    Karan

  • Unable to compile a package calling a package procedure in different schema

    Hello,
    I'm unable to compile a package referencing a package located in another schema. I get the message: PLS-00201: identifier 'pkg1' must be declared
    Facts:
    0. I'm running Oracle DB 10.2.0.4.0 Enterprise Edition
    1. There is one schema ('schema1') containing a package ('pkg1').
    2. This package 'pkg1' has a public synonym ('pkg1' as well).
    3. The EXECUTE grant is given to a role ('role1').
    4. There is another schema 'schema2', which is granted the role 'role1' (and set as default).
    5. This schema 'schema2' contains a package ('pkg2').
    6. This package 'pkg2' calls a procedure of 'pkg1'.
    7. When compiling 'pkg2', I get error message saying 'pkg1' does not exist.
    Of course, if I execute 'GRANT EXECUTE ON pkg1 TO PUBLIC' or 'GRANT EXECUTE ON pkg1 TO schema2', I can compile the package 'pkg2'. But I don't want this.
    And what's weird is that, connected as 'schema2', I can execute the statement 'execute pkg1.proc1' without any trouble. So I guess the role setup is okay.
    What would let me compile 'pkg2' properly?
    Regards,
    Arnaud

    user3347638 wrote:
    Hello,
    I'm unable to compile a package referencing a package located in another schema. I get the message: PLS-00201: identifier 'pkg1' must be declared
    Facts:
    0. I'm running Oracle DB 10.2.0.4.0 Enterprise Edition
    1. There is one schema ('schema1') containing a package ('pkg1').
    2. This package 'pkg1' has a public synonym ('pkg1' as well).
    3. The EXECUTE grant is given to a role ('role1').
    4. There is another schema 'schema2', which is granted the role 'role1' (and set as default).
    5. This schema 'schema2' contains a package ('pkg2').
    6. This package 'pkg2' calls a procedure of 'pkg1'.
    7. When compiling 'pkg2', I get error message saying 'pkg1' does not exist.
    Of course, if I execute 'GRANT EXECUTE ON pkg1 TO PUBLIC' or 'GRANT EXECUTE ON pkg1 TO schema2', I can compile the package 'pkg2'. But I don't want this.
    And what's weird is that, connected as 'schema2', I can execute the statement 'execute pkg1.proc1' without any trouble. So I guess the role setup is okay.
    What would let me compile 'pkg2' properly?
    Regards,
    Arnaudprivileges acquired via ROLE do NOT apply within named PL/SQL procedures.
    above is just a restriction built into PL/SQL.
    accept it & get on with reality

Maybe you are looking for

  • Time Dimensions and Logical dimension "..that not join to any fact source"

    Hi Guys, I get the following error on the ANSWERS front end: Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 14026] Unable to navigate requested

  • Optimum Settings for mini display to VGA

    I just got a mini display to VGA cord for my aluminum mac book and hooked it up to my 37" Vizio LCD HD tv and was wondering what the best settings would be to put it on as far as the resolution goes.

  • Cmos checksum error

    Getting cmos checksum error - defaults loaded press f1 to continue. Pc boots into windows and seems to work OK. Don't seem to be able to get rid of this message though at startuop. Any ideas, it's anew board, the bios hasn't been updated the bioard i

  • Handling acknowledgement for sender idoc from multiple receivers

    Hi, Problem: Sender IDOC mapped to multiple FILE receivers. So sender system is SAP, receivers are BS_SYS1, BS_SYS2 and BS_SYS3. The partner profile for IDOC is set as BS_SYS. Due to this, I can enter BS_SYS in the Adapter-Specific Identifiers of one

  • [CS5 - JS] Changing font

    Hi, is it possible to change all fonts within an ID document using a script? Most of the font object properties are read-only... Is there some kind of workaround for this? Thanks.