Reputation: 4934
I did go through the similar questions and their answers of SO but it didn't help. Here is my procedure:
DELIMITER //
DROP PROCEDURE IF EXISTS test//
CREATE PROCEDURE test()
BEGIN
DECLARE intime TIME;
SET intime:=(SELECT intime FROM new_attendance WHERE empid='xxx' AND DATE(dt)='2013-08-02');
SELECT intime;
END //
DELIMITER ;
When I execute this line of code it works and returns proper value:
SELECT empid FROM new_attendance WHERE empid='xxx' AND DATE(dt)='2013-08-02'
but it's not working inside procedure. i appreciate your help. Thanks a lot in advance!
Upvotes: 1
Views: 1421
Reputation: 3280
First of all, variable assignment in MySQL takes a =
syntax, not a :=
one.
EDIT: Strike the above, it seems that both syntaxes are supported after all...
Second, wouldn't be simpler to eliminate the intime
variable altogether and just do
DELIMITER //
DROP PROCEDURE IF EXISTS test//
CREATE PROCEDURE test()
BEGIN
SELECT intime FROM new_attendance WHERE empid='xxx' AND DATE(dt)='2013-08-02';
END //
DELIMITER ;
Upvotes: 3