Trigger
DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Trigger

  1. #1
    Join Date
    May 2001
    Location
    Brazil
    Posts
    13
    How can i reference a collumn of my table on Before Delete Trigger of this table?


    Thanks

  2. #2
    Join Date
    Mar 2001
    Location
    Ireland/Dublin
    Posts
    684
    You can't delete column without deletting a row.
    You may update it only.

    CREATE OR REPLACE TRIGGER TRG1
    before update OF "WORK_EMAIL2" ON "MEMBER_TBL"
    REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW
    begin
    ...
    ... :old.work_email2 ...
    ... :new.work_email2 ...
    end;

    CREATE OR REPLACE TRIGGER TRG1
    before delete ON "MEMBER_TBL"
    REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW
    begin
    ...
    ... :old.work_email2 ...
    end;


    Originally posted by margraf
    How can i reference a collumn of my table on Before Delete Trigger of this table?
    Thanks

  3. #3
    Join Date
    May 2001
    Location
    Brazil
    Posts
    13

    Thumbs down TRIGGER

    No, i don't want delete just a collumn. I want to delete a row from another table but i have to reference a collumn for this table.

    For Ex:

    Delete from another_table where collumn_another_table =
    collumn_table_of_trigger;

    How can i reference the collumn?


    Thanks.......

  4. #4
    Sorry, I don't know, but Why would you want to do that, the reference between the tables is not variable, it is not based on what column is modified, the reference existed before, so the trigger must be fixed.
    2 cents
    Ramon Caballero, DBA, rcaballe@yahoo.com

  5. #5
    Join Date
    Mar 2001
    Location
    Ireland/Dublin
    Posts
    684

    Lightbulb Re: TRIGGER

    Hey, I am sure you are talking about trigger on view !!!
    First of all you have to create view as
    select t1.*,t2* from t1,t2
    and then create 'INSTEAD OF TRIGGER' on view for the column are you interesting in.
    Best wishes!

    Originally posted by margraf
    No, i don't want delete just a collumn. I want to delete a row from another table but i have to reference a collumn for this table.

    For Ex:

    Delete from another_table where collumn_another_table =
    collumn_table_of_trigger;

    How can i reference the collumn?


    Thanks.......

  6. #6
    Join Date
    May 2001
    Location
    Brazil
    Posts
    13

    TRIGGER

    I didn't understand, can you explain?


    I want to do delete cascade without use this clause, I want to create a trigger for this...... Because sometimes I have values in the second table that no appear in the first table..

  7. #7
    Join Date
    Mar 2001
    Location
    Ireland/Dublin
    Posts
    684

    Re: TRIGGER

    O'k if you would like to delete cascade you may not use a trigger at all:
    Do like that:

    ALTER TABLE address_reminder_tbl
    ADD ( FOREIGN KEY (rem_id)
    REFERENCES reminder_calendar_tbl on delete cascade) ;

    And when you delete from the parent table all records will be deleted from the doughters tables.

    Originally posted by margraf
    I didn't understand, can you explain?


    I want to do delete cascade without use this clause, I want to create a trigger for this...... Because sometimes I have values in the second table that no appear in the first table..

  8. #8
    Well, just do it, Have you tried and you've got an error message?
    Ramon Caballero, DBA, rcaballe@yahoo.com

  9. #9
    Join Date
    Mar 2001
    Location
    Ireland/Dublin
    Posts
    684
    I don't try, I am using that!

    Originally posted by rcaballe
    Well, just do it, Have you tried and you've got an error message?

  10. #10
    JE JE, my post was for Margraf. See you
    Ramon Caballero, DBA, rcaballe@yahoo.com

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