Inserting elapsed time
Posted: Wed Oct 18, 2006 9:04 pm
feyd | Please use [/syntax]
Any help is appreciated.
Thanks.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I am not where I going wrong.
I have a table, in which I am trying to capture elapsed time between start time and end time. Please see below for information:
[syntax="sql"]CREATE TABLE `article_art` (
`id_art` int(11) NOT NULL auto_increment,
`title_art` varchar(255) NOT NULL default '',
`content_art` text NOT NULL,
`createdon_art` datetime NOT NULL default '0000-00-00 00:00:00',
`modifiedon_art` datetime NOT NULL default '0000-00-00 00:00:00',
`time_submit` timestamp NOT NULL default CURRENT_TIMESTAMP,
`time_diff` varchar(15) default NULL,
PRIMARY KEY (`id_art`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;
INSERT INTO `article_art` VALUES (24, 'test', 'test', '2006-10-18 17:21:48', '0000-00-00 00:00:00', '2006-10-18 17:21:53', NULL);
// trigger:
create trigger
location.test
AFTER
INSERT
on
location.article_art
for each row UPDATE article_art set time_differ=time_submit-createdon_artCode: Select all
Error:
SQL error: Can't update table 'article_art' in stored function/trigger because it is already used by statement which invoked this stored function/trigger..
SQL error: INSERT INTO article_art (title_art, content_art, createdon_art) values ('test', 'test', '2006-10-18 17:21:48'). (SQL_ERROR)Any help is appreciated.
Thanks.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]