DBAsupport.com Forums - Powered by vBulletin
Results 1 to 9 of 9

Thread: Trigger problems

  1. #1
    Join Date
    Dec 2000
    Location
    Brazil / São Paulo
    Posts
    97

    Trigger problems

    I have to trigger in the table the one that brings up to date two other tables (B and C), when I give error of constraint in one of brought up to date tables (B or C), the table and the one that error gave suffers ROLLBACK, however to another one not. How to proceed?
    Márcio de Souza Almeida
    DBA Oracle / SQLServer / PostgreSQL
    Rua Cupa, 139 Apto 85 A
    Penha - São Paulo - SP
    03640-000 - Brasil
    http://www.directory.com.br

  2. #2
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    All I can understand is... ROLLBACK.

    try increasing the space of ur ROLLBACK.
    Cheers!
    OraKid.

  3. #3
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Is this what you mean?

    1) Update to A triggers updates to B and C.
    2) Update to C fails due to constraint error.
    3) Updates to A and C are rolled back, but update to B is not rolled back.

    If so, it sounds like you have a commit in the trigger - something you should normally NOT do.

  4. #4
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Originally posted by DaPi
    Is this what you mean?

    1) Update to A triggers updates to B and C.
    2) Update to C fails due to constraint error.
    3) Updates to A and C are rolled back, but update to B is not rolled back.

    If so, it sounds like you have a commit in the trigger - something you should normally NOT do.
    I don't think that commit in trigger is allowed.

    Code:
    create table my_table (col1 number);
    
    create or replace trigger my_trigger before insert on my_table
    for each row
    begin null;
    commit;
    end;
    /
    
    insert into my_table values (1)
                *
    ERROR at line 1:
    ORA-04092: cannot COMMIT in a trigger
    ORA-06512: at "KEYSTONE_STAGE.MY_TRIGGER", line 2
    ORA-04088: error during execution of trigger 'KEYSTONE_STAGE.MY_TRIGGER'
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  5. #5
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Originally posted by slimdave
    I don't think that commit in trigger is allowed.
    Ooops - I only tried compiling it
    Of course, it can only be trapped at execution 'coz the commit could be in a proc called from the trigger. (I assume we're not talking about autonomous transactions . . . .)

  6. #6
    Join Date
    Dec 2000
    Location
    Brazil / São Paulo
    Posts
    97

    Exclamation

    In trigger three functions are executed, however in none of them it has commit.
    Tables B and C are in another bank, this make some difference?
    Márcio de Souza Almeida
    DBA Oracle / SQLServer / PostgreSQL
    Rua Cupa, 139 Apto 85 A
    Penha - São Paulo - SP
    03640-000 - Brasil
    http://www.directory.com.br

  7. #7
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    You CANNOT give commit or rollback within a FUNCTION()
    Cheers!
    OraKid.

  8. #8
    Join Date
    Dec 2000
    Location
    Brazil / São Paulo
    Posts
    97

    Angry

    Do NOT have commit or rollback in this functions.
    Márcio de Souza Almeida
    DBA Oracle / SQLServer / PostgreSQL
    Rua Cupa, 139 Apto 85 A
    Penha - São Paulo - SP
    03640-000 - Brasil
    http://www.directory.com.br

  9. #9
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598

    Thumbs up

    Mr. marcio.68
    Cheers!
    OraKid.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width