Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    17

    Question Unanswered: is there any BEFORE INSERT TRIGGER in sybase??

    Dear Friends,
    Ive like to know is there any BEFORE INSERT TRIGGER in sybase??. if so is it available in all versions??. also any examples available for the same??.

    Any help in this regard is appreciated .

    Warm Regards,
    Vignesh

  2. #2
    Join Date
    Sep 2004
    Location
    Stockholm, Sweden
    Posts
    28
    Sybase ASE only offers AFTER-triggers. BEFORE-triggers are available in Sybase ASA, example:

    create trigger myTrigger
    before update on myTable
    begin
    ...
    end

    see ASA SQL Reference for details

    /Mats

  3. #3
    Join Date
    Sep 2009
    Posts
    1
    You can use this trick to implement before insert trigger in sybase ASE:
    create trigger myTrigger on myTable
    for insert
    as
    begin
    rollback -- you rollback your insert
    -- here some before insert action
    insert into myTable select * from inserted -- and here your make insert again
    end
    go

    but, I'm not sure then it's useful for all situations

  4. #4
    Join Date
    Mar 2009
    Location
    Sydney, Australia
    Posts
    258
    Sybase ASE only offers AFTER-triggers.
    That is incorrect, Sybase ASE has only "before" triggers, that is, the trigger is fired after you INSERT/UPDATE/DELETE starts (when you submit the statement to the server) and before the rows are INSERTed, within the context of your transaction. The trigger code inspects a virtual table "inserted", which contains the rows you are attempting to INSERT, which you can manipulate (eg. DELETE from inserted); and has full capability on the rest of the database for verifying the attempted INSERT.
    Regards
    Derek Asirvadem (Formerly DerekA)
    Information Architect / Senior Sybase DBA
    Copyright 2009 Software Gems Pty Ltd

    I answer questions from the Original Poster only. If you have a genuine question, as the moderators have requested, start a new thread.

    http://www.softwaregems.com.au

Posting Permissions

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