Triggers!
Posted: Wed 06 Jun 2007 21:14
Im trying to create a siple trigger using/chaning the demo example.
The trigger in design mode:
BEGIN
UPDATE test.articles SET = test.articles.nofs_instock
(SELECT SUM(stock.the_change) FROM test.stock
WHERE stock.id_article = articles.id_art )
END
In text-mode:
CREATE TRIGGER test.trigger1 AFTER INSERT
ON test.articles FOR EACH ROW BEGIN
UPDATE test.articles SET = test.articles.nofs_instock
(SELECT SUM(stock.the_change) FROM test.stock
WHERE stock.id_article = articles.id_art )
END
When i try to save it i get an error (that i cant copy...)
You have an error i n yoyr SQL syntax ...Update test.article SER = test.articles.nofs_instock (select SUM (stock.the_' at line 3
*** The database:
CREATE DATABASE /*!32312 IF NOT EXISTS*/ test
CHARACTER SET latin1
COLLATE latin1_swedish_ci;
USE test;
--
-- Table structure for table articles
--
CREATE TABLE `articles` (
`id_art` int(11) NOT NULL auto_increment,
`nofs_instock` int(11) default NULL,
PRIMARY KEY (`id_art`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Table structure for table stock
--
CREATE TABLE `stock` (
`id_change` int(11) NOT NULL auto_increment,
`id_article` int(11) default NULL,
`the_change` int(11) default NULL,
PRIMARY KEY (`id_change`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
The trigger in design mode:
BEGIN
UPDATE test.articles SET = test.articles.nofs_instock
(SELECT SUM(stock.the_change) FROM test.stock
WHERE stock.id_article = articles.id_art )
END
In text-mode:
CREATE TRIGGER test.trigger1 AFTER INSERT
ON test.articles FOR EACH ROW BEGIN
UPDATE test.articles SET = test.articles.nofs_instock
(SELECT SUM(stock.the_change) FROM test.stock
WHERE stock.id_article = articles.id_art )
END
When i try to save it i get an error (that i cant copy...)
You have an error i n yoyr SQL syntax ...Update test.article SER = test.articles.nofs_instock (select SUM (stock.the_' at line 3
*** The database:
CREATE DATABASE /*!32312 IF NOT EXISTS*/ test
CHARACTER SET latin1
COLLATE latin1_swedish_ci;
USE test;
--
-- Table structure for table articles
--
CREATE TABLE `articles` (
`id_art` int(11) NOT NULL auto_increment,
`nofs_instock` int(11) default NULL,
PRIMARY KEY (`id_art`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Table structure for table stock
--
CREATE TABLE `stock` (
`id_change` int(11) NOT NULL auto_increment,
`id_article` int(11) default NULL,
`the_change` int(11) default NULL,
PRIMARY KEY (`id_change`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;