

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to display message from a stored procedure?
To display message from stored procedure on the basis of conditions, let us use IF-ELSE condition −
mysql> DELIMITER // mysql> CREATE PROCEDURE showMessage(value int,Name varchar(20)) BEGIN IF(value > 100) then SELECT CONCAT("HELLO"," ",Name); ELSE SELECT CONCAT("BYE"," ",Name); END IF; END // Query OK, 0 rows affected (0.18 sec) mysql> DELIMITER ;
Case 1 − Call the stored procedure using CALL command, when value is more than 100 −
call showMessage(200,'John');
This will produce the following output −
+--------------------------+ | CONCAT("HELLO"," ",Name) | +--------------------------+ | HELLO John | +--------------------------+ 1 row in set (0.00 sec) Query OK, 0 rows affected, 1 warning (0.02 sec)
Case 2 − When the value is less than 100, a difference message will be visible since ELSE condition will execute −
mysql> call showMessage(10,'John');
This will produce the following output −
+------------------------+ | CONCAT("BYE"," ",Name) | +------------------------+ | BYE John | +------------------------+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.01 sec)
- Related Questions & Answers
- Display table records from a stored procedure in MySQL
- Display description of MySQL stored procedure
- How to quit/ exit from MySQL stored procedure?
- How can a MySQL stored procedure call another MySQL stored procedure inside it?
- What is STORED PROCEDURE in a DB2? How will you create a new stored procedure?
- How to create MongoDB stored procedure?
- How to retrieve multiple ResultSets from a stored procedure using a JDBC program?
- Display records from MySQL stored Procedure with IF…THEN…END IF statements
- MySQL Stored Procedure to create a table?
- How can I create a stored procedure to delete values from a MySQL table?
- How to loop thrugh a stored procedure in MySQL?
- How to suppress MySQL stored procedure output?
- How can we alter a MySQL stored procedure?
- How can we drop a MySQL stored procedure?
- MySQL stored procedure to return a column value?
Advertisements