MySQL Forums
Forum List  »  Stored Procedures

Creating a stored procedure that counts book written by author.
Posted by: Josef Lundström
Date: September 01, 2017 10:21AM

Hello!

I am trying to create a stored procedure in MYSQL, which I intend to count books in a table that is written by a certain author:


DELIMITER //
CREATE PROCEDURE CountBooks()
BEGIN
DECLARE bookCounter INTEGER;

SELECT COUNT(*)
INTO bookCounter
FROM book
WHERE bookAuthor LIKE 'Vlad Tepec';
END //

CALL CountBooks,(bookCounter);
SELECT @bookCounter;

DROP PROCEDURE IF EXISTS CountBooks;


@bookCounter is null... How can I modify the stored procedure to get the expected result?
Thanks!

Options: ReplyQuote


Subject
Views
Written By
Posted
Creating a stored procedure that counts book written by author.
3697
September 01, 2017 10:21AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.