Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2008
    Posts
    13

    Unanswered: PLEASE HELP - Trigger For Duplicate Rows

    I need a trigger to prevent duplicate rows.

    I want to add a trigger named t1 to the products table.The trigger is activated by the Before Insert event.

    Any ideas..
    Last edited by MaryH; 10-10-08 at 06:38.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    as ever the manuel is your friend

    what have you tries so far, where are the problems arising
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What's wrong with a unique or primary key constraint?
    George
    Home | Blog

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by georgev
    What's wrong with a unique or primary key constraint?
    it's a homework assignment, that's what's wrong with it

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    This looks like a trick question to me then; the answer the marker is looking for is "do not use a trigger, declare an appropriate constraint instead"
    George
    Home | Blog

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    how would a constraint work in MySQL?
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    AFAIK you can declare as many constraints as you wish.. the problem is that they are not actually implemented. they are there for compatability reasons but dont' actually do anything as yet. that as certainly the case in May 2007
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    That is for CHECK constraints, which are something different.
    George
    Home | Blog

  10. #10
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    UNIQUE constraints work perfectly well in MySQL

    you guys should stop reading the doom 'n gloom naysayers and actually put yer hands on this little beauty

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  11. #11
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by r937
    you guys should stop reading the doom 'n gloom naysayers and actually put yer hands on this little beauty
    Is that supposed to be an inuendo?
    George
    Home | Blog

  12. #12
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by georgev
    Is that supposed to be an inuendo?
    if you can't come in through your front door, try in yer window
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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