Can we use semicolon as a MySQL DEMILITER?


No, we cannot. If you still did it, then stored procedure won’t get created. Therefore, first you need to change your DELIMITER from semicolon(;) to others like (// ,??..etc). Following is the syntax −

DELIMITER //
CREATE PROCEDURE yourProcedureName()
BEGIN
yourStatement1,
.
.
.
.
N
END
//
DELIMITER ;

Let us implement the above syntax in order to create a stored procedure −

mysql> DELIMITER //
mysql> CREATE PROCEDURE get_Message()
   -> BEGIN
   -> SELECT CONCAT("HELLO"," ","MYSQL USERS");
   -> END
   -> //
Query OK, 0 rows affected (0.23 sec)
mysql> DELIMITER ;

Now you can call the stored procedure with the help of CALL command −

mysql> CALL get_Message();

Output

This will produce the following output −

+-----------------------------------+
| CONCAT("HELLO"," ","MYSQL USERS") |
+-----------------------------------+
| HELLO MYSQL USERS                 |
+-----------------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.01 sec)

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 30-Jun-2020

77 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements