SQL
A community portal about SQL with blogs, videos, and photos. According to Wikipedia.org: SQL is the most popular computer language used to create, modify, retrieve and manipulate data from relational database management systems. The... [more]
A community portal about SQL with blogs, videos, and photos. According to Wikipedia.org: SQL is the most popular computer language used to create, modify, retrieve and manipulate data from relational database management systems. The language has evolved beyond its original purpose to support object-relational database management systems. It is an ANSI / ISO standard.
Trigger Error 1064
animaldetails
Animal_Id int (primary key)
IsMilking varchar (Yes/NO)
Milking_Capacity varchar
milking
Animal_Id int (primary key)
MonthYear varcahr (eg. '6 2009' -- June 2009)
Day1 varchar
Day2 varchar
and so on (till 31)
milkingevent
TrigPoint int (primary key)
Requirements:
1. I require a trigger for table3 After update.
Loop 1
2. In table 1 it will search in each row for attribute IsMilking if it is YES it will store value of Milking_Capacity in an variable1 as well as Animal_Id in another variable2.
Loop2
3. Now it should go to table 2 search for Animal_Id from variable2. and Match with current month and year
4.
* If no record is found INSERT statement "Insert into table2..." values (variable2, current(month and Year), { eg. if to days date is 1 then value of variable1 in Day1 and reset all others to default value)
* If record exists in milking table, Update statement "Update into table2 ..." (where if current date is 28 then set value in Day 28 reset should be as it is.....)
5. After it gets completed Go to loop 1 and search for Second animal ID and the process continues.
MYSQL:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++
ERROR DISPALYED ARE
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@_lAnimal_Idint INT' at line 3
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @_lIsMilking INTEGER DEFAULT 0' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @_lMilking_Capacity VARCHAR(50) DEFAULT ""' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @_lMonth_Year VARCHAR(50) DEFAULT ""' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @_lCount INTEGER DEFAULT 0' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @_lAnimal_Id INTEGER DEFAULT 0' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE Table1_CUR CURSOR FOR SELECT Milk_Capacity,Animal_Id FROM animaldetails ' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPEN Table1_CUR' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FETCH Table1_CUR INTO @_lMilking_Capacity,@_lAnimal_Idint' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @_lMonth_Year= SELECT CONCAT(MONTH(current_date) ,' ', YEAR(current_date))' at line 2
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Select COUNT(*) FROM milking WHERE Animal_Id=@_lAnimal_Idint AND MonthYear=@_lMo' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF @_lCount>0
BEGIN
IF (DAY(current_date)='26')
BEGIN
Update milking' at line 1
(0 ms taken)
Animal_Id int (primary key)
IsMilking varchar (Yes/NO)
Milking_Capacity varchar
milking
Animal_Id int (primary key)
MonthYear varcahr (eg. '6 2009' -- June 2009)
Day1 varchar
Day2 varchar
and so on (till 31)
milkingevent
TrigPoint int (primary key)
Requirements:
1. I require a trigger for table3 After update.
Loop 1
2. In table 1 it will search in each row for attribute IsMilking if it is YES it will store value of Milking_Capacity in an variable1 as well as Animal_Id in another variable2.
Loop2
3. Now it should go to table 2 search for Animal_Id from variable2. and Match with current month and year
4.
* If no record is found INSERT statement "Insert into table2..." values (variable2, current(month and Year), { eg. if to days date is 1 then value of variable1 in Day1 and reset all others to default value)
* If record exists in milking table, Update statement "Update into table2 ..." (where if current date is 28 then set value in Day 28 reset should be as it is.....)
5. After it gets completed Go to loop 1 and search for Second animal ID and the process continues.
MYSQL:
Code:
ERROR DISPALYED ARE
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@_lAnimal_Idint INT' at line 3
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @_lIsMilking INTEGER DEFAULT 0' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @_lMilking_Capacity VARCHAR(50) DEFAULT ""' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @_lMonth_Year VARCHAR(50) DEFAULT ""' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @_lCount INTEGER DEFAULT 0' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @_lAnimal_Id INTEGER DEFAULT 0' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE Table1_CUR CURSOR FOR SELECT Milk_Capacity,Animal_Id FROM animaldetails ' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPEN Table1_CUR' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FETCH Table1_CUR INTO @_lMilking_Capacity,@_lAnimal_Idint' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @_lMonth_Year= SELECT CONCAT(MONTH(current_date) ,' ', YEAR(current_date))' at line 2
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Select COUNT(*) FROM milking WHERE Animal_Id=@_lAnimal_Idint AND MonthYear=@_lMo' at line 1
(0 ms taken)
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF @_lCount>0
BEGIN
IF (DAY(current_date)='26')
BEGIN
Update milking' at line 1
(0 ms taken)
Related Articles
Comments
Be the first to leave a comment!
About the Author
From Our Partners
People in Pictures
Top Geek Articles
|
Celebrities on the Phone
Cell phones are to celebrities like bats are to baseball: no one runs too far without them.
|
|
Why every guy should buy their girlfriend Wii Fit.
Gratuitous...
|
|
Hot Geeks -- The Sexiest Geeky Girls
These girls are gorgeous AND they'll play Warcraft with you. Doesn't get much better than that.
|




