Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003
    Posts
    2

    Unanswered: Triggers in PostGres

    hi,

    we are doing the migration of Oracle PL/SQL scripts to Postgres Plpgsql.

    So my question is how do I write the equivalent code for INSTEAD OF DELETE clause in a PL/SQL trigger to PostGres..


    CREATE OR REPLACE TRIGGER JCP_CODE_VALUES_VL_INSERT
    INSTEAD OF INSERT ON JCP_CODE_VALUES_VL
    REFERENCING NEW AS new
    FOR EACH ROW


    Regards

    Joe

  2. #2
    Join Date
    Aug 2003
    Posts
    3
    If your action is reasonably uncomplicated, you can write it as a Rule instead of a Trigger. You can declare rules as "do instead" and it works the way you'd expect. See http://www.postgresql.org/docs/7.3/i...eaterule.html.

    Otherwise, PG triggers work by calling functions that can operate on the "new" and "old" rows. See http://www.postgresql.org/docs/aw_pg.../node166.html. So, you could update the new row to the old, then do whatever else you want. Maybe there is a better way to tell it to skip the update but I'm not aware of one. Again rules are simpler if what you want to do fits what they can do.

Posting Permissions

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