
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Use delimiter correctly in a MySQL stored procedure to avoid BEGIN/END statements errors
Such errors arise when you avoid using the DELIMITER concept. Let us see an example and run a query for stored procedure −
mysql> DELIMITER // mysql> CREATE PROCEDURE correct_procedure() BEGIN SELECT 'Hello MySQL !!!'; END // Query OK, 0 rows affected (0.12 sec) mysql> DELIMITER ;
Following is the syntax to call the stored procedure −
call yourStoredProcedureName();
Call the stored procedure using CALL command −
mysql> call correct_procedure();
This will produce the following output −
+-----------------+ | Hello MySQL !!! | +-----------------+ | Hello MySQL !!! | +-----------------+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.02 sec)
- Related Articles
- How to correctly use DELIMITER in a MySQL stored procedure?
- How to correctly use delimiter in a MySQL stored procedure and insert values?
- How to correctly implement END IF statement in a MySQL Stored Procedure?
- Create a stored procedure with delimiter in MySQL
- How to correctly implement conditions in MySQL stored procedure?
- Display records from MySQL stored Procedure with IF…THEN…END IF statements
- How can we use prepared statements in a stored procedure?
- How to use FOR LOOP in MySQL Stored Procedure?
- How can we create MySQL stored procedures without ‘BEGIN’ and ‘END’?
- How to correctly use INSERT INTO … SELECT in MySQL to avoid Error 1064?
- Use IN() to get only a particular record in a MySQL stored procedure?
- How to use IF in stored procedure and select in MySQL?
- How can a MySQL stored procedure call another MySQL stored procedure inside it?
- How do I avoid the variable value in a MySQL stored procedure to change when records are updated?
- MySQL Stored Procedure to create a table?

Advertisements