Results 1 to 4 of 4
  1. #1
    Join Date
    May 2008
    Posts
    10

    Unanswered: keep an insert from working, if field matches

    so I have a sybase 12.5 db, with a table of phone numbers.
    If the phone number is blank, or 000 000 0000, I need the insert to fail.

    I can't 'fix' it from the front-end, as I have no control over the utility that does the insert.

    I know there's a way to do this, but I'm having trouble figuring it out.

    Thanks

  2. #2
    Join Date
    Jun 2010
    Posts
    51
    Use insert trigger.
    Please always reply to the post if it was helpful. Others may find it helpful.

  3. #3
    Join Date
    May 2008
    Posts
    10
    thoughts on why this one don't work ?


    Code:
    create trigger test_phone
        on phone_table
        for insert,update
        as
        if update(phone) in ("0000000000","000","")
        begin
            rollback transaction
        end
    Keeps giving a error on IN

  4. #4
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    You probably want something like this
    Code:
    if update(phone)
      if exists (select 1 from inserted where phone in ("0000000000","000",""))
        rollback transaction

Posting Permissions

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