Shell script to validate all invalid objects?

Hello DBA's.
New to DBA ing and so seek your help.. I am using oracle Oracle9i Release on a Solaris box.
I need a shell script that will check all invalid objects on a DB and would validate it by running utlrp.sql. I know i can do this manually but i am asked to automate the process..
Kindly suggest where i can find a shell script or share this script with me.. it would be much appreciated.
Regards!

OK, this is possible, and here is one way entirely within SQL*Plus where it will try once more to recompile invalid objects, please note that this (top one) will work only on 11g or greater, and only getting around to testing this properly now:
#!/bin/ksh
. $HOME/.profile
export ORACLE_SID=<your_SID>
sqlplus '/ as sysdba' << EOF
set serveroutput on
set pagesize 1000
@${ORACLE_HOME}/rdbms/admin/utlrp.sql
begin
for cur  in (select do.owner || '.' || do.object_name module, object_type from dba_objects do join obj$ o on (do.object_id = o.obj#) where o.status = 5)
loop
begin
execute immediate 'alter ' || cur.object_type || ' ' || cur.module  || ' compile';
exception when others then continue;
end;
end loop;
end;
spool <path_and_filename_of_your_Invalid_Objects_output_file>
select do.owner || '.' || do.object_name from dba_objects do join obj$ o on (do.object_id = o.obj#) where o.status = 5;
spool off
quit
EOF
exit $?For < 11g:
#!/bin/ksh
. $HOME/.profile
export ORACLE_SID=<your_SID>
sqlplus '/ as sysdba' << EOF
set serveroutput on
set pagesize 0
set heading off
set termout off
set feedback off
@${ORACLE_HOME}/rdbms/admin/utlrp.sql
spool /tmp/recompile.sql
begin
for cur  in (select do.owner || '.' || do.object_name module, object_type from dba_objects do join obj$ o on (do.object_id = o.obj#) where o.status = 5)
loop
dbms_output.put_line( 'alter ' || cur.object_type || ' ' || cur.module || ' compile;');
end loop;
end;
spool off
@/tmp/recompile.sql
!rm /tmp/recompile.sql
set heading on
set termout on
set pagesize 1000
spool <path_and_filename_of_your_Invalid_Objects_output_file>
select do.owner || '.' || do.object_name from dba_objects do join obj$ o on (do.object_id = o.obj#) where o.status = 5;
spool off
quit
EOF
exit $?Edited by: SeánMacGC on Apr 29, 2009 1:12 PM

Similar Messages

  • Recompile all invalid objects in live database

    Hi Expers,
    Just need a clarification on recompiling all invalid objects in production database when the systems is busy.
    i thought of recompile all the invalid objects using utlrp.sql script in my production database since some of few synonyms were invalid after application patch script been implemented last weekeend.
    we have identifed the invalid objects now, i thought to run the utlrp.sql, what will be the consequences.
    Regards,
    Salai

    Hi Hemanth,
    I'd reserve utlrp.sql for upgrades, downgrades and patchsets. I do agree 101% with above point, I a not denying on that.
    If you really have a large number of invalid objects, you might choose to compile a few "selected" objects every hour instead of running a single-shot "compile all invalid objects". Rare but a possible requirement.I came across such requirement during early days of career during pushing product enhancement to production and we would have get to know the things and number of objects which would go invalid as we use to carry out testing on test databases.
    I agree completely utlrp.sql is suggested and should opt for.
    - Pavan Kumar N

  • To compile all invalid objects

    how we can compile all invalid objects? is there any sample plsql code?

    dbms_utility.compile_schema('shema_name');Please note that from Oracle 9i onwards this does not work. It compiles objects in alphabetical order rather than reverse dependency order, so you may end up with more objects uncompiled than you started with. This change occurred due to the introduction of Java (boo! hiss!) which allows circular dependencies.
    Since then, the only safe way to compile objects is to use the %ORACLE_HOME%\rdbms\admin\utlirp.sql script (which requires sysdba access).
    This has been packaged up in 10gR2 as UTL_RECOMP.
    Thereby proving that searching is easy but finding the right answer is difficult.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • How to compile all invalid objects in SQL Developer

    Hi
    I am used to PL\SQL Developer and currently I am testing SQL Developer (version 2.1). I have question where can I find in SQL Developer functionality (or how to invoke those functions) like:
    1 ) To list all invalid objects and then compile them.
    2) Invoke window similar to “Command window” in PL\Sql Developer
    Thanks for help
    Groxy

    Could I please revive this and ask how do I use UTL_RECOMP?
    Also, I could not find a description of the icons in SQL Developer. Some procedures are shown with a green plus sign (I am guessing here since I can't make out what it is) on them and the ones that I right-click and compile have this green go away. Can you explain?
    Thanks a lot.

  • How to recompile all invalid objects of APPS?

    Dear all:
    How to recompile all invalid objects of APPS? my environment is ORACLE 9.2.0.5 32bit.
    Regards
    Terry

    varun4dba wrote:
    hi Terry,
    did you tried adadmin?
    thanks.Do you mean:
    Compile/Reload Database Objects
    1. Compile APPS schema
    2. Compile menu information
    3. Recreate grants and synonyms for APPS schema
    4. Compile flexfield data in AOL tables
    5. Reload JAR files to database
    6. Return to Main Menu

  • CURSOR to recompile all INVALID objects

    Ok, I know I'm using the atler-compile pre-defined trigger here, and I'm cool with that.
    I'm creating an anonymous block to recompile all INVALID objects. I've come up with a basic CURSOR to pull all INVALID objects into the cursor, and then using the alter_compile trigger to recomipile them.
    However, I can't figure out how to call them all into the trigger...One of the inputs for the alter_compile trigger is the name of the object...hwo can I get around that?
    DECLARE
    CURSOR compile_cur
      IS
       SELECT object_name, status
        FROM user_objects
         WHERE status='INVALID';
    BEGIN
    FOR rec_cur IN compile_cur LOOP
      DBMS_DDL.ALTER_COMPILE('PROCEDURE', 'SYSTEM','BB_JOBTEST');
    END LOOP;
    END;
    /

    You can issue a single statement to compile all triggers, procedures, packages, functions in the schema.
    SQL> EXEC DBMS_UTILITY.compile_schema(schema => 'Schema_Name');
    This will compile all the objects regardless of it's current status.
    Shailender Mehta

  • Script to copy all the objects within a Stored Procedure

    I am trying to copy all the objects from one database to another using Scripts. Now I need to put that script inside a Stored Procedure.
    Thanks.

    Refer this vbscript to generate all object scripts programatically,
    http://www.codeproject.com/Articles/16195/How-to-Script-Out-SQL-Server-Objects
    or
    Using SSMS
    http://msdn.microsoft.com/en-IN/library/hh245282.aspx#GenPubScriptWiz
    Regards, RSingh

  • Power Shell Script to pull all deactivated users

    Has anyone written a script to pull a list of deactivated users?
    my goal is to validate sharepoint administrators in AD to see if they are active or deactivated. Any insight would be appreciated.

    yes. sorry for not making that clear. I found a few examples to enter in a user name to check AD, but i need to do that with a list of names instead rather than one by one.
    Hi,
    Here's a few possibilities:
    Returns all disabled AD accounts -
    Search-ADAccount -AccountDisabled
    Checks each username listed -
    $usersToCheck = 'tester1','tester2','tester3','tester4'
    foreach ($user in $usersToCheck) {
    If (((Get-ADUser $user).Enabled) -eq $true) { Write-Host "$user is enabled in AD" -ForegroundColor Green }
    Else { Write-Host "$user is disabled in AD" -ForegroundColor Red }
    Reads a text file of usernames and checks those -
    Get-Content .\userList.txt | ForEach {
    If (((Get-ADUser $_).Enabled) -eq $true) { Write-Host "$_ is enabled in AD" -ForegroundColor Green }
    Else { Write-Host "$_ is disabled in AD" -ForegroundColor Red }
    Don't retire TechNet! -
    (Don't give up yet - 12,575+ strong and growing)

  • How to create power shell script to upload all termset csv files into the SharePoint2013 local taxonomy ?

    Hi Everyone,
    I want to create a powershell script file
    1) Check a directory and upload all termset csv files into the SharePoint local taxonomy.
    2) Input paramaters - directory that containss termset csv files, Local Termstore to import to,
    3) Prior to updating get a backup of the existing termstore (for rollback/recovery purposes)
    4) Parameters should be passed in via XML file.
    Please let me know how to do it.
    Regards,
    Srinivas

    Hi,
    Please check this link
    http://termsetimporter.codeplex.com/
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Power shell script to list all files and folder permissions recursively

    Hi All,
    I am looking for a powershell script to perform the following operations.
    1) To list the folder and file permissions(Allow,Deny both) recursively in a given folder.
    2) List out all the files and folders which are having the deny permission or having only the read access (or) only the write access. Basically the folder should have Read,Execute,Write permissions. Else we have to flag that file/folder name.
    I had written a batch script for the same which does this task using icacls.exe output, but this script takes lot of time to recursively parse all the files ( ~1 lakh files).
    Please help me with the powershell script for the same.
    Thanks
    Sambasiva

    Try this module: http://gallery.technet.microsoft.com/scriptcenter/PowerShellAccessControl-d3be7b83
    After importing the module, you can run something like this:
    dir c:\folder -recurse | Get-AccessControlEntry
    That output can be exported to a CSV for later viewing. You can also provide some parameters to Get-AccessControlEntry to limit the results:
    dir c:\folder -recurse | Get-AccessControlEntry -FileRights Write
    dir c:\folder -recurse | Get-AccessControlEntry -AceType AccessDenied
    dir c:\folder -recurse | Get-AccessControlEntry -AceType AccessAllowed -FileRights Write

  • Need shell Script for Invalid object

    Hi All,
    Can anyone post me a script for checking the invalid objects in 10g/11g database.
    The should should check for invalid objects,recompile and sent the email .

    I could think fo something like below(And applicable to multiple SID's running on the server) and i tested it it works(bash shell script)
    Assumptions:
    You have environmental file to set ORACLE_HOME ORACLE_SID
    say in this example
    /oracle/env
    ls -ltr
    env_ORCL.sh
    env_TEST.sh
    env_HR.sh
    You also have uuencode rpm installed to use along with mailx command(or else get it installed not big deal). uuencode is required
    to send as mail attachment
    1)I have kept SID list in file (/oracle/INVALID directory for eg)
    cat SID.lst
    ORCL
    TEST
    HR
    If you have lot of SID's you can populate the file using ( ps -ef|grep -i pmon | grep -v grep | awk '{print$9}' | sed 's/ora_pmon_//g' > SID.lst)
    2) Here are the list of SQL's(/oracle/INVALID directory
    cat invalid_pre.sql (For listing invalid objects per instance)
    set echo off
    set heading off
    set time off
    set timing off
    spool invalid.log append
    break on instance_name
    select instance_name , a.*
    from (select owner,count(*) from dba_objects where status='INVALID' group by owner) a, v$instance;
    spool off
    exit;
    cat invalid_compile.sql--to recompile invalid objects
    set echo off
    set termout off
    set feedback off
    @?/rdbms/admin/utlrp.sql 4; (Note you change degree 4 or 8 accordingly)
    exit;
    cat invalid_post.sql--to list post recompilation
    set echo off
    set heading off
    set time off
    set timing off
    spool invalid_post.log append
    break on instance_name
    select instance_name , a.*
    from (select owner,count(*) from dba_objects where status='INVALID' group by owner) a, v$instance;
    spool off
    exit;
    3)here is the shell script
    cat invalid.sh
    for i in `cat SID11g.lst`
    do
    cd /oracle/env/
    source env_$i.sh
    cd /oracle/INVALID
    sqlplus "/as sysdba" @invalid_pre.sql
    sqlplus "/as sysdba" @invalid_compile.sql
    sqlplus "/as sysdba" @invalid_post.sql
    done
    uuencode invalid.log invalid.log | mailx -s "Invalid" <your mail id>
    uuencode invalid_post.log invalid_post.log | mailx -s "Invalid" <your mail id>
    4) Finally run the shell script, hopefully you should receive email :-)
    I have tested it on bash
    ./invalid.sh
    Once tested you can schedule it in cron
    Edited by: vreddy on Jul 19, 2012 9:57 AM

  • Shell Scripts: "Open [ALL] With" Emacs

    Hi All,
    I'm trying to figure out a way to open ALL shell scripts (for which I use the extension ".sh") with emacs (launched in the terminal) by default.
    I've made some progress towards this goal, but am stuck on the last step. Here's what I've done:
    [1] I copied an Apple Script (from here: http://hints.macworld.com/article.php?story=20031027142625782) to create an Application (which I've called "Emacs_open_with.app"), that when launched with a file, will open it in emacs in the terminal.
    [2] I can make Emacs_open_with.app the default launch app for a individual shell script by right-clicking -> Open With -> Other... -> Emacs_open_with.app (+ check the box "Always Open With). However, doing this will only make it the default app for that single shell script, not for all of them, as I desire.
    [3] Normally, one can associate an application with a file extension, such that any file with that extension will be launched by default by this associated application, by: Right-clicking a file -> Get Info -> Open With -> Other... -> [DESIRED APP] (+ check the box "Always Open With) -> Change All... -> Click Continue when the pop-up appears which asks "Are you sure you want to change all similar documents to open with the application...". However, this does NOT work for Emacs_open_with.app; as soon as I click continue, the drop-down menu which I had used to select "Emacs_open_with.app" changes back to another, different Application.
    Any idea about how best to tackle this problem? Thanks for your help!

    Ilmari Aalto wrote:
    Hi Darth,
    Thanks for your hint! Nevertheless I think it's something more profound, since there's no error etc. For example, should I have the path wrong I assume that OWB would return me some kind of an error when it doesn't find the .sh-file? Isn't there any log-file to see whether the command was executed? It seems like the execution of the User Defined element would be skipped altogether.
    Cheers,
    IlmariNo, if you don't give an absolute path OWB will not return any error, it just wont do anything at all...

  • Checking database availability with shell script

    can anyone help with a script that checks for database availability before 10 P.M and 7 A.M at 5 minites interval and starts a SQL Load of a table once the db is available.
    I have no Shell script experience at all but I can amend an already written script.
    Please Help !!

    Dear Timothy,
    Within the Oracle software you have installed on your machine, there is a script called "dbstart" within the <ORACLE_HOME>/bin directory. This script provided by Oracle can be easily modified to check whether the server is up and should help solve your problem.
    Ciao!

  • How to write a shell script

    Hi,
    I am trying to learn to write shell script.
    Can anybody guide me throught this:
    I want to write a shell script that finds all the processes running in a database and then kill all these processes.

    Thanks Jen,
    I tried it and it worked.
    One question:
    What should I do to create a file and write a script in that file, so that when I run the file it will automatically kill the processes that are currently running.
    Should I use a "loop".
    I appreciate your help amd time.

  • Finding Invalid objects in schema

    Dear All,
    How to find all invalid objects in an paticular schema
    Regards,
    Raju

    Hello Raju
    SQL> select object_type,count(*) from user_objects where status = 'INVALID'
    2 group by object_type;
    OBJECT_TYPE COUNT(*)
    PACKAGE BODY 4
    PROCEDURE 61
    VIEW 3
    next, as sys
    exec dbms_utility.compile_schema( 'ACCOUNTS' );
    PL/SQL procedure successfully completed.
    then,
    connect accounts
    SQL> select object_type,count(*) from user_objects where status = 'INVALID'
    group by object_type;
    OBJECT_TYPE COUNT(*)
    PACKAGE BODY 1
    PROCEDURE 182
    VIEW 3
    try this
    Ravi
    http://dbaoraclefaqs.blogspot.com/

Maybe you are looking for

  • Currency Conversion on Daily Basis

    Hello We have data in 4 different currencies in transactions level and I have a requirement in BW to convert the currency on Daily basis based on that day's exchange rate. And Also I should be giving the user a selection option to pick a currency typ

  • Imessage not functioning with restrictions 'on'

    I just updated my iphone 4 to OS5. I activated imessage but when I turn restrictions 'on' imessage reverts to 'off' The restrictions that I have are : Facetime and Ping are 'off' and location and accounts are set to 'no change'. I can't see any logic

  • Auth for creating PO : SAP R3, Oracle 9i, Sun Solaris

    Hi experts, I need to give authorizations as follows. 1. Auth for creating PO (ME21N) for 10 users of Document type (M_BEST_BSA =All) 2. Auth for creating PO (ME21N) for 20 users of Document type (M_BEST_BSA =UB) 3. Display of POs (ME23N) to all 30 u

  • Can't Activate Flash Media Encoder CS3

    I just had a new hard drive installed on my Windows XP SP3, 4 GB RAM, 2 dual core Intel processors machine.  I reinstalled Production Premium CS3.  All of my Adobe applications activated except Flash Media Encoder CS3.  When I enter my serial number,

  • Where can I find 7.1 cabl

    I have an Audigy 2 ZS Notebook. The soundcard supports 7., but I cannot seem to find 7. cables for it. It has only 3 line-out jacks, two of them has to support 3-speakers each (including one subwoofer), and the the third line-out jack only supports 2