<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: MySQL: Solution for ERROR 1442 (HY000): Can&#8217;t update table &#8216;t1&#8242; in stored function/trigger because it is already used by statement which invoked this stored function/trigger.</title>
	<atom:link href="http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/feed/" rel="self" type="application/rss+xml" />
	<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/</link>
	<description>Enterprise level solutions, LAMP, Linux, Apache, MySQL, PHP, Perl, Windows, Cache, Optimization</description>
	<lastBuildDate>Thu, 11 Mar 2010 21:21:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cometinv3</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-904</link>
		<dc:creator>cometinv3</dc:creator>
		<pubDate>Tue, 15 Dec 2009 03:57:11 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-904</guid>
		<description>hola una pregunta nesecito ayuda nesecito hacer un trigger que cuando yo borre de una tabla un registro lo compare con una segunda tabla si el registro que fue borrado se en cuentra en la segunda tabla con el disparador se elimine cual seria mi solucion gracias espero sus respuestas en mysql podrian poner las posibles soluciones;


yo cree este trigger pero no se si esta bien

------------------------------
delimiter //
create trigger borrar
after delete on animales
for each row begin
delete animales,concursos from concursos,animales 
where animales.cve_animal = concursos.cve_animal;
end
// delimiter
------------------------------------

saludos</description>
		<content:encoded><![CDATA[<p>hola una pregunta nesecito ayuda nesecito hacer un trigger que cuando yo borre de una tabla un registro lo compare con una segunda tabla si el registro que fue borrado se en cuentra en la segunda tabla con el disparador se elimine cual seria mi solucion gracias espero sus respuestas en mysql podrian poner las posibles soluciones;</p>
<p>yo cree este trigger pero no se si esta bien</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
delimiter //<br />
create trigger borrar<br />
after delete on animales<br />
for each row begin<br />
delete animales,concursos from concursos,animales<br />
where animales.cve_animal = concursos.cve_animal;<br />
end<br />
// delimiter<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>saludos</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: toro</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-890</link>
		<dc:creator>toro</dc:creator>
		<pubDate>Mon, 19 Oct 2009 04:03:20 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-890</guid>
		<description>I use it and work find

DELIMITER &#124;

CREATE TRIGGER shop_insert
  BEFORE INSERT
  ON shops
  FOR EACH ROW
BEGIN
  IF NEW.shop_id = NEW.shop_id THEN
  SET NEW.created = NOW();
  END IF;
END

DELIMITER ;</description>
		<content:encoded><![CDATA[<p>I use it and work find</p>
<p>DELIMITER |</p>
<p>CREATE TRIGGER shop_insert<br />
  BEFORE INSERT<br />
  ON shops<br />
  FOR EACH ROW<br />
BEGIN<br />
  IF NEW.shop_id = NEW.shop_id THEN<br />
  SET NEW.created = NOW();<br />
  END IF;<br />
END</p>
<p>DELIMITER ;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jatin</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-859</link>
		<dc:creator>Jatin</dc:creator>
		<pubDate>Wed, 24 Jun 2009 11:23:20 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-859</guid>
		<description>I got a msg when creating a view. 

Error Code : 1142
CREATE VIEW command denied to user &#039;root&#039;@&#039;user.com&#039; for table &#039;tbl_ABC&#039;


thanks in Advance..</description>
		<content:encoded><![CDATA[<p>I got a msg when creating a view. </p>
<p>Error Code : 1142<br />
CREATE VIEW command denied to user &#8216;root&#8217;@'user.com&#8217; for table &#8216;tbl_ABC&#8217;</p>
<p>thanks in Advance..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jhon Pierre</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-850</link>
		<dc:creator>Jhon Pierre</dc:creator>
		<pubDate>Wed, 10 Jun 2009 14:38:25 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-850</guid>
		<description>I have a same problem. I create a trigger AFTER INSERT on tabla1 , in it i want to UPADTE the same tabla1 . But when i insert a row, i get the next error:

Error Code : 1442
Can&#039;t update table &#039;cuentacontable&#039; in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
(32 ms taken)

Please. Help me, Thanks.</description>
		<content:encoded><![CDATA[<p>I have a same problem. I create a trigger AFTER INSERT on tabla1 , in it i want to UPADTE the same tabla1 . But when i insert a row, i get the next error:</p>
<p>Error Code : 1442<br />
Can&#8217;t update table &#8216;cuentacontable&#8217; in stored function/trigger because it is already used by statement which invoked this stored function/trigger.<br />
(32 ms taken)</p>
<p>Please. Help me, Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yayan suryaman</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-849</link>
		<dc:creator>yayan suryaman</dc:creator>
		<pubDate>Mon, 01 Jun 2009 15:31:30 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-849</guid>
		<description>php myadmin error</description>
		<content:encoded><![CDATA[<p>php myadmin error</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alvaro Oliver</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-831</link>
		<dc:creator>Alvaro Oliver</dc:creator>
		<pubDate>Wed, 29 Apr 2009 19:40:35 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-831</guid>
		<description>Michael, TMD: same problem here!
what about updating different row in the same triggered table?</description>
		<content:encoded><![CDATA[<p>Michael, TMD: same problem here!<br />
what about updating different row in the same triggered table?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TMD</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-818</link>
		<dc:creator>TMD</dc:creator>
		<pubDate>Mon, 16 Mar 2009 09:45:31 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-818</guid>
		<description>i need a solution to update DIFFERENT row in same table too, who can help??</description>
		<content:encoded><![CDATA[<p>i need a solution to update DIFFERENT row in same table too, who can help??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Hasenstein</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-809</link>
		<dc:creator>Michael Hasenstein</dc:creator>
		<pubDate>Sun, 18 Jan 2009 02:23:03 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-809</guid>
		<description>Unfortunately this is NOT a solution to the problem. It only works if the record you want to update is the same record triggering the trigger.

What if I want to update a DIFFERENT row in the same table? For example, I&#039;ve a tree stored in the table and want to update the parent_id&#039;s in all affected rows when a row (node in the tree) is deleted. Impossible! What&#039;s more, there is no reason for this mysql behavior. I use INNODB, which should have row-level locks. I&#039;d understand the error in MYISAM tables which use table-locking.

Fact remains, it&#039;s a really stupid mySQL bug. Oh well, one more reason to use a REAL database like Oracle :-(</description>
		<content:encoded><![CDATA[<p>Unfortunately this is NOT a solution to the problem. It only works if the record you want to update is the same record triggering the trigger.</p>
<p>What if I want to update a DIFFERENT row in the same table? For example, I&#8217;ve a tree stored in the table and want to update the parent_id&#8217;s in all affected rows when a row (node in the tree) is deleted. Impossible! What&#8217;s more, there is no reason for this mysql behavior. I use INNODB, which should have row-level locks. I&#8217;d understand the error in MYISAM tables which use table-locking.</p>
<p>Fact remains, it&#8217;s a really stupid mySQL bug. Oh well, one more reason to use a REAL database like Oracle <img src='http://crazytoon.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Herman</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-789</link>
		<dc:creator>Herman</dc:creator>
		<pubDate>Mon, 17 Nov 2008 10:07:56 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-789</guid>
		<description>Hello!
I need a catalog tree table. How can I create trigger to check a column with &quot;level of subcatalog&quot;?
When some catalog moved into another all downlaying catalog must recount theirs level.
This is possible?</description>
		<content:encoded><![CDATA[<p>Hello!<br />
I need a catalog tree table. How can I create trigger to check a column with &#8220;level of subcatalog&#8221;?<br />
When some catalog moved into another all downlaying catalog must recount theirs level.<br />
This is possible?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tahir Mahmood</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-772</link>
		<dc:creator>Tahir Mahmood</dc:creator>
		<pubDate>Thu, 02 Oct 2008 07:34:27 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-772</guid>
		<description>Hi friend,
I am facing problem in creating database. Would you please help me.</description>
		<content:encoded><![CDATA[<p>Hi friend,<br />
I am facing problem in creating database. Would you please help me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sunny Walia</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-721</link>
		<dc:creator>Sunny Walia</dc:creator>
		<pubDate>Sun, 15 Jun 2008 23:29:49 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-721</guid>
		<description>Cane, please use forums for questions not related to posts.  I posted a correct table definition at:  http://crazytoon.com/forum/viewtopic.php?f=3&amp;t=6</description>
		<content:encoded><![CDATA[<p>Cane, please use forums for questions not related to posts.  I posted a correct table definition at:  <a href="http://crazytoon.com/forum/viewtopic.php?f=3&#038;t=6" rel="nofollow">http://crazytoon.com/forum/viewtopic.php?f=3&#038;t=6</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cane</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-720</link>
		<dc:creator>cane</dc:creator>
		<pubDate>Sun, 15 Jun 2008 03:19:26 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-720</guid>
		<description>Help with table, thanx up front!


DROP TABLE IF EXISTS `donations`;
CREATE TABLE `donations` (
  `id` int(11) NOT NULL auto_increment,
  `itemname` varchar(255) NOT NULL default &#039;&#039;,
  `gross_price` varchar(10) NOT NULL default &#039;&#039;,
  `pay_email` varchar(255) NOT NULL default &#039;&#039;,
  `paymentdate` date NOT NULL default &#039;0000-00-00&#039;,
  `firstname` varchar(100) default NULL,
  `lastname` varchar(100) default NULL,
  `memo` varchar(255) NOT NULL default &#039;&#039;,
  `paymentstatus` varchar(20) default NULL,
  `pendingreason` varchar(20) NOT NULL default &#039;&#039;,
  `txnid` varchar(30) NOT NULL default &#039;&#039;,
  `anom` char(3) NOT NULL default &#039;no&#039;,
  `stdate` date default NULL,
  KEY `paymentstatus` (`paymentstatus`),
  KEY `stdate` (`stdate`),
  KEY `txnid` (`txnid`)
) TYPE=MyISAM AUTO_INCREMENT=1;

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key.</description>
		<content:encoded><![CDATA[<p>Help with table, thanx up front!</p>
<p>DROP TABLE IF EXISTS `donations`;<br />
CREATE TABLE `donations` (<br />
  `id` int(11) NOT NULL auto_increment,<br />
  `itemname` varchar(255) NOT NULL default &#8221;,<br />
  `gross_price` varchar(10) NOT NULL default &#8221;,<br />
  `pay_email` varchar(255) NOT NULL default &#8221;,<br />
  `paymentdate` date NOT NULL default &#8216;0000-00-00&#8242;,<br />
  `firstname` varchar(100) default NULL,<br />
  `lastname` varchar(100) default NULL,<br />
  `memo` varchar(255) NOT NULL default &#8221;,<br />
  `paymentstatus` varchar(20) default NULL,<br />
  `pendingreason` varchar(20) NOT NULL default &#8221;,<br />
  `txnid` varchar(30) NOT NULL default &#8221;,<br />
  `anom` char(3) NOT NULL default &#8216;no&#8217;,<br />
  `stdate` date default NULL,<br />
  KEY `paymentstatus` (`paymentstatus`),<br />
  KEY `stdate` (`stdate`),<br />
  KEY `txnid` (`txnid`)<br />
) TYPE=MyISAM AUTO_INCREMENT=1;</p>
<p>#1075 &#8211; Incorrect table definition; there can be only one auto column and it must be defined as a key.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-719</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Tue, 10 Jun 2008 08:39:17 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-719</guid>
		<description>Thanks Tracy.  This drop/create trigger gambit appears to be standard methodology.  BUT, I am trying out Navicat and this seems to stand in the way of normal MySQL execution/saving/defining of MySQL objects.</description>
		<content:encoded><![CDATA[<p>Thanks Tracy.  This drop/create trigger gambit appears to be standard methodology.  BUT, I am trying out Navicat and this seems to stand in the way of normal MySQL execution/saving/defining of MySQL objects.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-627</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Thu, 06 Mar 2008 07:39:48 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-627</guid>
		<description>Thanks for the great post.  It helped me solve my problem with setting up my first trigger.</description>
		<content:encoded><![CDATA[<p>Thanks for the great post.  It helped me solve my problem with setting up my first trigger.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Haddad</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/comment-page-1/#comment-607</link>
		<dc:creator>Jonathan Haddad</dc:creator>
		<pubDate>Tue, 04 Mar 2008 02:53:27 +0000</pubDate>
		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comment-607</guid>
		<description>I actually had to read through this twice, because I was working on something similar at the time.  If you&#039;re trying to do an update-join, and one of the tables has a trigger that updates the other table in the join, it will fail.  

For example, if you have these tables:
picture (pictureid, name, num_comments)
comment (commentid, pictureid, userid, comment, num_ratings), 
rating (commentid, userid, rating)

Pictures have comments, comments have ratings.

If you&#039;re trying to copy a foreign key from the comments to the ratings (say the pictureid, for performance reasons), and you have a trigger on ratings to update an aggregate in comments (in this case, the rating count), this query will fail:

update comment c JOIN rating r on c.commentid = r.commentid 
set r.pictureid = c.pictureid;

You could get around it by only having the trigger fire if the rating changes.</description>
		<content:encoded><![CDATA[<p>I actually had to read through this twice, because I was working on something similar at the time.  If you&#8217;re trying to do an update-join, and one of the tables has a trigger that updates the other table in the join, it will fail.  </p>
<p>For example, if you have these tables:<br />
picture (pictureid, name, num_comments)<br />
comment (commentid, pictureid, userid, comment, num_ratings),<br />
rating (commentid, userid, rating)</p>
<p>Pictures have comments, comments have ratings.</p>
<p>If you&#8217;re trying to copy a foreign key from the comments to the ratings (say the pictureid, for performance reasons), and you have a trigger on ratings to update an aggregate in comments (in this case, the rating count), this query will fail:</p>
<p>update comment c JOIN rating r on c.commentid = r.commentid<br />
set r.pictureid = c.pictureid;</p>
<p>You could get around it by only having the trigger fire if the rating changes.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
