
- 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
MySQL stored-procedure: out parameter?
Here is a stored procedure that takes one parameter for input (IN) and second parameter for output (OUT)
mysql> delimiter // mysql> create procedure Sp_SQRT(IN Number1 INT, OUT Number2 FLOAT) -> Begin -> set Number2=sqrt(Number1); -> end; -> // Query OK, 0 rows affected (0.24 sec) mysql> delimiter ;
Call the stored procedure and send the value to the user variable. The syntax is as follows
CALL yourStoredProcedureName(anyIntegerValue,@anyVariableName);
Check what value is stored in the variable @anyVariableName. The syntax is as follows
SELECT @anyVariableName;
Created the stored procedure with the name ‘Sp_SQRT’. The query is as follows to call the stored procedure
mysql> call Sp_SQRT(36,@MySquareRootNumber); Query OK, 0 rows affected (0.02 sec)
Check the value of variable @MySquareRootNumber using select statement
mysql> select @MySquareRootNumber;
The following is the output
+---------------------+ | @MySquareRootNumber | +---------------------+ | 6 | +---------------------+ 1 row in set (0.00 sec)
- Related Articles
- How can I create MySQL stored procedure with OUT parameter?
- How can I create MySQL stored procedure with IN parameter?
- How can I create MySQL stored procedure with INOUT parameter?
- How can a MySQL stored procedure call another MySQL stored procedure inside it?
- MySQL stored procedure return value?
- Display description of MySQL stored procedure
- How to use an OUT parameter / read data with SELECT from table in a MySQL procedure?
- How can we invoke MySQL stored procedure?
- View stored procedure/function definition in MySQL?
- MySQL Stored Procedure to create a table?
- How to suppress MySQL stored procedure output?
- Set conditions in a MySQL stored procedure
- Implement DELETE query in MySQL stored procedure
- How can we alter a MySQL stored procedure?
- How can we drop a MySQL stored procedure?

Advertisements