If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > PLEASE HELP - Trigger For Duplicate Rows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-09-08, 06:27
MaryH MaryH is offline
Registered User
 
Join Date: Oct 2008
Posts: 13
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 05:38.
Reply With Quote
  #2 (permalink)  
Old 10-09-08, 06:30
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
as ever the manuel is your friend

what have you tries so far, where are the problems arising
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 10-09-08, 07:00
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
What's wrong with a unique or primary key constraint?
__________________
George
Twitter | Blog
Reply With Quote
  #4 (permalink)  
Old 10-09-08, 07:18
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 10-09-08, 08:06
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #6 (permalink)  
Old 10-09-08, 08:17
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
how would a constraint work in MySQL?
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #7 (permalink)  
Old 10-09-08, 08:21
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
__________________
George
Twitter | Blog
Reply With Quote
  #8 (permalink)  
Old 10-09-08, 08:29
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #9 (permalink)  
Old 10-09-08, 08:38
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
That is for CHECK constraints, which are something different.
__________________
George
Twitter | Blog
Reply With Quote
  #10 (permalink)  
Old 10-09-08, 11:07
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #11 (permalink)  
Old 10-09-08, 11:34
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #12 (permalink)  
Old 10-09-08, 13:16
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On