
- 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 suppress MySQL stored procedure output?
To suppress MySQL stored procedure output, you can use variable. Let us first create a table.
mysql> create table person_information -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.50 sec)
Following is the query to insert some records in the table using insert command:
mysql> insert into person_information values(100,'John'); Query OK, 1 row affected (0.17 sec) mysql> insert into person_information values(101,'Chris'); Query OK, 1 row affected (0.22 sec) mysql> insert into person_information values(102,'Robert'); Query OK, 1 row affected (0.16 sec)
Following is the query to display records from the table using select command:
mysql> select *from person_information;
This will produce the following output
+------+--------+ | Id | Name | +------+--------+ | 100 | John | | 101 | Chris | | 102 | Robert | +------+--------+ 3 rows in set (0.00 sec)
Here is the query to suppress MySQL stored procedure output:
mysql> DELIMITER // mysql> CREATE PROCEDURE sp_supressOutputDemo() -> BEGIN -> set @output=(select Name from person_information where id=101); -> END -> // Query OK, 0 rows affected (0.14 sec) mysql> DELIMITER ;
You can call the above stored procedure using CALL command:
mysql> call sp_supressOutputDemo(); Query OK, 0 rows affected (0.00 sec)
After calling the above stored procedure, we are not getting anything. Therefore, you need to use select statement to get the output.
Following is the query
mysql> select @output;
This will produce the following output
+---------+ | @output | +---------+ | Chris | +---------+ 1 row in set (0.00 sec)
- Related Articles
- How can a MySQL stored procedure call another MySQL stored procedure inside it?
- How to quit/ exit from MySQL stored procedure?
- How to call a stored procedure that returns output parameters, using JDBC program?
- How can we invoke MySQL stored procedure?
- How to use FOR LOOP in MySQL Stored Procedure?
- How to loop thrugh a stored procedure in MySQL?
- How to correctly implement conditions in MySQL stored procedure?
- MySQL stored-procedure: out parameter?
- MySQL stored procedure return value?
- MySQL Stored Procedure to create a table?
- How can we alter a MySQL stored procedure?
- How can we drop a MySQL stored procedure?
- How to check whether a stored procedure exist in MySQL?
- How to generate 5 random numbers in MySQL stored procedure?
- How to correctly use DELIMITER in a MySQL stored procedure?

Advertisements