My SQL script (sproc.sql):
use timetable_db;
DROP PROCEDURE IF EXISTS GetEmptyClassrooms;
delimeter |
CREATE PROCEDURE GetEmptyClassrooms()
BEGIN
SELECT room_number,seats from classrooms WHERE room_number not in (SELECT room_number FROM timetable);
END |
When I try to import it to MySQL via the phpmyadmin GUI I got the errors:
Unexpected beginning of command. (near "delimiter" at position 0)
Sorry, the default language is not English in my MySQL. I tried to translate as precisely as I can.
I've read several posts here in S.overflow about similar errors but I couldn't solve it.
There are solutions to solve this, but not much help because in the end I want to use only the "my db name . sql" script including all the create tables, insert rows...etc and of course the create procedures, everything in one, simply importable file.
I tried:
I'm really a beginner in SQL but I want to improve myself.
Thanks for the help :)
I think there is error in syntax which you are using. Please try below way.
DROP procedure IF EXISTS `GetEmptyClassrooms`;
DELIMITER $$
USE `test`$$
CREATE PROCEDURE `GetEmptyClassrooms` ()
BEGIN
SELECT room_number,seats from classrooms
WHERE room_number not in (SELECT room_number FROM timetable);
END
$$
DELIMITER ;
where test is the database name where you want to create the stored procedure