Jump to content


Photo

Triggers: Inserting row into a second table...


  • Please log in to reply
4 replies to this topic

#1 Jim R

Jim R
  • Members
  • PipPipPip
  • Advanced Member
  • 499 posts

Posted 06 September 2017 - 04:47 PM

I've found numerous ideas on how to do this.  Here is my current query:

Action:  After
Event:  Insert (a_players)*

insert wp_termsset name = concat(NEW.nameFirst,' ',NEW.nameLast), slug = concat(NEW.nameFirst,'-',NEW.nameLast)

* a_players is the table and not showing the in trigger window.  

 

 

I've tried to do it as a Before, but I already have a Before trigger, and for some reason I can't have two Befores.  

 

 

I'm getting this error:

 

Can't update table 'a_players' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

 

 

However, it does insert the new row into wp_terms.  The problem is I'm getting that error, prompting me cancel and it's inputting the row  twice.  



#2 requinix

requinix
  • Administrators
  • Lazy Administrator
  • 9,135 posts
  • LocationWA

Posted 06 September 2017 - 04:58 PM

:facewall:

I feel like you haven't learned anything from the last couple threads. I'm pretty sure I linked you to some documentation. Did you read any of it? How much of what I've said regarding updating the table and modifying NEW did you understand?
The Reimann Zeta Function Trolley Problem | "Stop! You're spoiling my unjustified indignation!"

#3 Jim R

Jim R
  • Members
  • PipPipPip
  • Advanced Member
  • 499 posts

Posted 06 September 2017 - 05:26 PM

I felt like you missed me.   :happy-04:

 

If the issue is Before vs After, it's not letting me have multiple Before Triggers off the same table.  

 

What you linked the other day, I had already read.  I'm trying NEW in various places, including NEW.name and NEW.slug, with and without use of other NEWs.  Maybe I've missed a combination.  



#4 Jim R

Jim R
  • Members
  • PipPipPip
  • Advanced Member
  • 499 posts

Posted 06 September 2017 - 05:43 PM

 

 

This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'


#5 Jim R

Jim R
  • Members
  • PipPipPip
  • Advanced Member
  • 499 posts

Posted 13 September 2017 - 01:41 PM

Here is my current attempt, still not working:

Trigger from a_players

After Insert --

insert into wp_terms
set name = concat(NEW.nameFirst,' ',NEW.nameLast), slug = concat(NEW.nameFirst,'-',NEW.nameLast)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users