
- 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
How to correctly use delimiter in a MySQL stored procedure and insert values?
Let us first create a table −
mysql> create table DemoTable2028 -> ( -> StudentFirstName varchar(20), -> StudentLastName varchar(20) -> ); Query OK, 0 rows affected (0.87 sec)
Here is the query to create a stored procedure and insert values (using delimiter correctly) −
mysql> delimiter // mysql> create procedure insert_name(in fname varchar(20),in lname varchar(20)) -> begin -> insert into DemoTable2028 values(fname,lname); -> end -> // Query OK, 0 rows affected (0.17 sec) mysql> delimiter ;
Call the stored procedure using CALL command −
mysql> call insert_name('Chris','Brown'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable2028;
This will produce the following output −
+------------------+-----------------+ | StudentFirstName | StudentLastName | +------------------+-----------------+ | Chris | Brown | +------------------+-----------------+ 1 row in set (0.00 sec)
- Related Articles
- How to correctly use DELIMITER in a MySQL stored procedure?
- Use delimiter correctly in a MySQL stored procedure to avoid BEGIN/END statements errors
- Create a stored procedure with delimiter in MySQL
- How to correctly implement conditions in MySQL stored procedure?
- How can I create a stored procedure to insert values in a MySQL table?
- How to correctly implement END IF statement in a MySQL Stored Procedure?
- Insert values in two tables with a single stored procedure call in MySQL
- Insert data in a table in MySQL stored procedure?
- How to use IF in stored procedure and select in MySQL?
- How to use FOR LOOP in MySQL Stored Procedure?
- Can we use stored procedure to insert records into two tables at once in MySQL?
- Create a table inside a MySQL stored procedure and insert a record on calling the procedure
- MySQL Stored Procedure calling with INT and VARCHAR values
- How can a MySQL stored procedure call another MySQL stored procedure inside it?
- How to correctly use INSERT INTO … SELECT in MySQL to avoid Error 1064?

Advertisements