Recompilation of all triggers in a schema.

Hi folks!
I got a gotcha!
I'd changed couple of table structures here and there in the schema and subsequently, quite understandably, all the triggers that are related to the afore-altered tables went into invalid status.
It is taking a toll on me to again recompile each and every trigger in the schema.
How do I recompile all the triggers in the entire schema with the help of a single statement?
Your favour'll be deeply appreciated.
Cheers, PCZ.

I'd changed couple of table structures here and there
in the schema and subsequently, quite understandably,
all the triggers that are related to the
afore-altered tables went into invalid status.
It is taking a toll on me to again recompile each and
every trigger in the schema.
How do I recompile all the triggers in the entire
schema with the help of a single statement?
Your favour'll be deeply appreciated.
Cheers, PCZ.I wana know why you need explicitly recompile all triggers when implicit recompilation exist there??
SQL> CREATE OR REPLACE TRIGGER mytrigger BEFORE UPDATE ON emp FOR EACH ROW
  2  BEGIN
  3  IF :new.sal>100 THEN
  4    RAISE_APPLICATION_ERROR(-2001,'No valid update');
  5  END IF;
  6  END;
  7  .
SQL> /
Trigger created.
SQL> SELECT object_name,status FROM all_objects WHERE object_type='TRIGGE
OBJECT_NAME                    STATUS
MYTRIGGER                      VALID
SQL> ALTER TABLE emp ADD (a  NUMBER);
Table altered.
SQL> SELECT object_name,status FROM all_objects WHERE object_type='TRIGGE
OBJECT_NAME                    STATUS
MYTRIGGER                      INVALID
SQL> UPDATE emp SET sal=200 WHERE deptno=20;
UPDATE emp SET sal=200 WHERE deptno=20
ERROR at line 1:
ORA-21000: error number argument to raise_application_error of -2001 is out of range
ORA-06512: at "SCOTT.MYTRIGGER", line 3
ORA-04088: error during execution of trigger 'SCOTT.MYTRIGGER'
SQL> SELECT object_name,status FROM all_objects WHERE object_type='TRIGGER';
OBJECT_NAME                    STATUS
MYTRIGGER                      VALIDKhurram

Similar Messages

  • Disabled triggers in apps schema

    Hi all
    In my apps schema i can see too many triggers that are disabled!
    Is this a normal situation?
    I have lately convert my apps to multi-org.I have read some doc in metalink, that this situation can happen when converting to multi-org.
    Do i have to enable all of them?
    Thanks in advance, Soni

    Hi Soni,
    When converting to multi org all triggers are disabled and at the end enabled again (using a list created when starting the convert to multi org) when the conversion fails for example it will cause lots of invalid triggers.
    See the following:
    When starting Convert to multo org it first creates a Disable triggers script:
    $APPL_TOP/admin/<SID>/PROD//out/orgcnvdt.sql"
    and it will also create a script to enable them again:
    $APPL_TOP/admin/<SID>/PROD/out/orgcnvet.sql
    When the conversion fails somehow and you did not run the enable script before restarting you will endup with lost of disabled triggers from which you don't know which should be enabled.
    If this is your test environment and you don't have the enable script anymore I would suggest to Create a new test environment as that will be faster then letting support fix the issue (possible not even possible)
    In case of PROD and you don't have the enable script, then you have a serious problem as triggers are needed for everything, when you have triggers disabled which should be enabled it could cause data inconsistency, in that case contact Support asap as suggested already.
    Good luck with it.
    Regards,
    Ronald

  • All triggers went invalid

    Hi All,
    Today morning when I was looking into the database I saw that all the triggers in the schema got invalid. Then I checked the alert log but no errors. And even I was unable to find
    any suspected activity or a query.
    What can be the reason.
    SQLTRACE is ON and can any body tell any suggestions or reasons or any queries with TKPROF.
    Thanks,
    G.

    Thanks Laurent,
    This is the thing that I have done previously
    If you revoke privileges from a schema object, dependent objects are cascade invalidated.The schema has DBA privilege and i revoked it and then granted limited privileges.
    But When I grant privileges Dont they get automatically valid?
    This what I have done.
    Revoke dba from schema1;
    grant all privileges to schema1;
    revoke insert any table from schema1;
    Thanks,
    G.

  • Can we export DATA from all tables in a schema?

    Hi,
    I have a question; Can we export all the DATA from all the tables present in the schema to any source (eigther CSV, TXT, DAt, etc..)?
    Or
    Can I have a PL/SQL procedure to display DATA from all Tables in a schema?
    With Best Regards,
    - Naveed

    Hi,
    This is pretty much what you need.
    DECLARE
    V_COUNT NUMBER;
    v_sql varchar2(1000);
    IN_OWNER_NAME VARCHAR2(100) := 'AP' ; -- SCHEMA NAME
    TYPE T_COL_NAME is table of varchar2(1000) index by binary_integer;
    v_col_tbl t_col_name;
    BEGIN
    FOR i in
    (SELECT object_name
    FROM dba_objects
         WHERE owner = IN_OWNER_NAME
         AND object_type ='TABLE'
    and rownum < 2)
    LOOP
    v_sql := 'SELECT COUNT(*) FROM ' || i.object_name ;
    EXECUTE IMMEDIATE v_sql INTO V_COUNT;
    if v_count > 0 then
    v_sql := 'SELECT * FROM ' || i.object_name ;
    select column_name
    bulk collect
    into v_col_tbl
    from DBA_TAB_COLUMNS
    WHERE TABLE_NAME = I.OBJECT_NAME
    AND OWNER = IN_OWNER_NAME;
    -- start selecting the column and exporting using the column names selected.     
    end if;
    if v_col_tbl.count > 0 then
    for i in v_col_tbl.first .. v_col_tbl.last
    loop
    DBMS_OUTPUT.PUT_lINE(v_col_tbl(i));
    end loop;
    end if;
    DBMS_OUTPUT.PUT_lINE( i.object_name || '-' || v_count);
    END LOOP;
    END;
    - Ronel

  • How to delete all rows in all tables of a schema in Oracle?

    Hi all,
    I want to delete all records of all tables of a schema and I think there should be some statement for this but I don't know how?
    may you help?
    Edited by: user8105261 on Nov 25, 2009 11:06 PM

    user8105261 wrote:
    Hi all,
    I want to delete all records of all tables of a schema and I think there should be some statement for this but I don't know how?
    may you help?
    Edited by: user8105261 on Nov 25, 2009 11:06 PMA typical way to reset a schema (e.g. to recreate a schema on the test database) is totally different.
    1) Drop the user
    2) recreate the user including table scripts from
    2a) your version control system
    2b) from a export dumpfile using the "nodata" option while importing

  • List of all columns in a schema?

    Is there a view that can be queried for all the columns and their properties for all tables in a schema?
    Thanks in advance for any help.
    Cheers,
    Frank J. Reashore
    Vancouver, Canada

    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_4459.htm#sthref3346

  • How to view text of all triggers?

    How to view text of all triggers?
    I tried,
    sqlplus "/ as sysdba"
    SQL> Select Description, Trigger_Body from all_triggers;
    I see only one trigger but there are more than 500 triggers.

    Perhaps you want to query DBA_TRIGGERS instead of ALL_TRIGGERS.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_4162.htm#sthref1922
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2107.htm#sthref1297

  • Droping all tables in a schema

    how to drop all tables in a schema with out logging in that schema and having logged in as sys user?
    Thanks in advance
    Edited by: Prasanna.N on May 17, 2010 11:48 PM

    Prasanna.N wrote:
    Hi,
    i get this error
    ERROR at line 5:
    ORA-06550: line 5, column 9:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the
    following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-identifier>
    <a bind variable> << close current delete fetch lock insert
    open rollback savepoint set sql execute commit forall merge
    pipe
    when giving
    begin
    for t in (select table_name from dba_tables where owner = 'SCOTT')
    loop
    execute immediate 'drop table SCOTT.' || t.table_name || 'purge';
    end loop;
    /I just wrote for loop, of course you have to write inside begin..end block:
    begin
    for t in (select table_name from dba_tables where owner = 'SCOTT')
    loop
    execute immediate 'drop table SCOTT.' || t.table_name || '  purge';
    end loop;
    end;
    /

  • Need to grant DML privileges to all tables in few schemas

    Hi,
    I need to grant DML privileges to all tables in few schemas to a role. How can I achieve that?
    I thought it's below syntax but it doesn't work. Please advice.
    grant ALL ON ALL TABLES IN SCHEMA <Schema_name>  TO <role_name>;Thanks,
    Gangadhar

    GR wrote:
    Hi,
    I need to grant DML privileges to all tables in few schemas to a role. How can I achieve that?
    I thought it's below syntax but it doesn't work. Please advice.
    grant ALL ON ALL TABLES IN SCHEMA <Schema_name>  TO <role_name>;
    There is no single command to grant privileges at that level. There are either ANY privileges or privileges on an object.
    You can write a bit of code to generate and execute what you want, but you would have to rerun it if any new tables were created.

  • Grant select on all table of a schema to role

    Hi , is it possible to grant select on all table on a schema to a role?

    To grant SELECT on all tables of the current schema to particular role or user:
    SELECT 'GRANT SELECT ON '||TABLE_NAME||' TO READ_ONLY_ROLE;' COMMAND
    FROM (
    SELECT TABLE_NAME
    FROM ALL_TABLES
    WHERE OWNER = (SELECT USER FROM DUAL)
    Then copy and execute the result commands, eg:
    GRANT SELECT ON DEPT TO READ_ONLY_ROLE;
    GRANT SELECT ON EMP TO READ_ONLY_ROLE;
    GRANT SELECT ON DEMO_USERS TO READ_ONLY_ROLE;
    GRANT SELECT ON DEMO_CUSTOMERS TO READ_ONLY_ROLE;
    GRANT SELECT ON DEMO_ORDERS TO READ_ONLY_ROLE;

  • All columns of all table in one schema

    Hi
    All,
    Oralce 10.2.0.3
    I want to count all columns in all the table in one particular schema.
    How can I do that?
    which view i should use to count all cloumns of all tables in particular schema?
    Thanks

    vishal patel wrote:
    we needed for our data conversion project..I don't know how you'll use the number of columns in all a schema for data conversion. Some columns are duplicated (e.g. PK/FK), should they really count for two ?
    A data conversion means you should actually know what are the columns used for, not how many they are.
    one more question that count include hidden columns
    what is hidden column used for ? I can not see those columns in actual table.See here an example :
    Re: Difference btwn user_tab_cols & user_tab_columns
    Nicolas.

  • Program (PL/SQL) for count the registers of all tables in a schema

    Hi...
    I create a little program , for count the registers of all tables in the schema...
    If you need , send me your email...
    Atte
    Hector

    Hi,
    You can create a script by yourself by executing the script mentioned below:
    Connect as sys or system....
    SQL> spool test.sql
    SQL> select 'select count(*) from '||owner||'.'||table_name||';' from dba_tables;
    SQL> spool off;
    Hope this helps.
    Regards,
    -Praveen.
    http://myracle.wordpress.com

  • What privilege is needed to browse all tables in a schema

    I used SQLPlus to login to DB. When I clicked "table" in the left side window, no tables is shown. What privilege is needed to browse all tables in a schema?
    Thanks.

    SQL*Plus is a command-line interface. There is no side window to click on. Perhaps you're talking about SQL Programmer? Or are you talking about some other tool?
    What user are you logging in as? What user owns the objects? Do you just want to see that the tables exist? Or do you want to be able to see the data as well?
    Justin

  • Need the find the all DDLs from the schema of 1 year old

    Hi,
    Can you please provide the information for the following databases, schemas within the given timeframe:
    - LMS_MX / BATCH_MX / JMS_MX
    – DWH_MX
    Start: 01.01.2013
    End: 31.12.2013
    We need all DDL from the schemas above.
    Thanks,
    Can anybody help me out ,?  how to find such details.?

    1978276 wrote:
    i dont no , how to use audit logs..? can anybody guide me to find the details of 1 year..
    Do you have auditing enabled? Default is not enabled for what you want to query. So unless you have specific auditing enabled, and the audit logs for that year period, you are out of luck.
    Thus, the details are not available as you did not instruct Oracle to record the details.
    Not an Oracle problem. Your problem.
    And as rp0428 said - this begs the question as just WHAT is your problem?

  • Input paramter--Trigger Starting String  _disable all triggers

    I want a procedure where input parameter is trigger's starting letter and the function shoudl disable all triggers starting with that name
    Please help me

    Hey,
    You can use this procedure:
    create or replace procedure p_disable_all_trg_by_letter(p_letter in varchar2,
    p_disable boolean,
    p_table boolean) is
    begin
    If p_table Then
    for i in (select trigger_name
    from user_triggers
    where table_name like upper(p_letter) || '%') loop
    execute immediate 'alter trigger ' || i.trigger_name || case when p_disable then ' disable ' else ' enable ' end;
    end loop;
    Else
    for i in (select trigger_name
    from user_triggers
    where trigger_name like upper(p_letter) || '%') loop
    execute immediate 'alter trigger ' || i.trigger_name || case when p_disable then ' disable ' else ' enable ' end;
    end loop;
    End If;
    end;
    Note that this procedure takes 3 argument's:
    a. the table or trigger name (could be one letter or more)
    b. boolean flag - true will disable the triggers, false will enable them
    c. boolean flag - true will search by the table name, false by the trigger name
    Amiel.

Maybe you are looking for