• gfoulks (3/12/2014)


    Hello,

    I've searched the internet looking for examples of a instead of trigger that I would like to setup but I've not been able to find anything that would really fit what I'm trying to do. What I'm trying to do seems simple enough but I can't seem to find the sql query to make it work.

    Basically I have a table that is used to capture some log data from an application. There are some rows that are being entered that I really don't need but I can't make an application change to prevent these rows from being entered in this table.

    What I want is a instead of trigger so that if a inserted row meets a set criteria then the row is automatically deleted. Thus keeping these rogue entries from being inserted into my table.

    Can anyone help with an example sql trigger that I could tweak to meet my specific needs?

    Thanks!

    based on your description, where you want to prevent some rows from being created, i'm not sure an instead of trigger is what you are after.

    what would be wrong with deleting existing rows periodically, if they meet the criteria you were describing?

    the trigger could insert data if it meets certain criteria, and ignore inserting if it did not meet criteria.

    show us the table definition, and the criteria to include/exclude rows, and we can help, if you are sure that's the way to go.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!