Two ways to write stored procedures in Mysql with and without return values

Two ways to write stored procedures in Mysql with and without return values

Process 1: with return value:

 drop procedure if exists proc_addNum;
 create procedure proc_addNum (in x int, in y int, out sum int)
 BEGIN
 SET sum = x + y;
 end

Then, execute the process and output the return value:

 call proc_addNum(2,3,@sum);
select @sum;

Procedure 2: Without return value:

 drop procedure if exists proc_addNum;
 create procedure proc_addNum (in x int, in y int)
 BEGIN
 DECLARE sum int;
 SET sum = x + y;
 SELECT sum;
 end

Execution process:

 call proc_addNum(2,3);

Summarize

The above is the two ways of writing MySQL stored procedures with and without return values ​​that I introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time!

You may also be interested in:
  • Simple writing of MYSQL stored procedures and functions
  • Detailed example of MySQL data storage process parameters
  • Detailed explanation of MySQL stored procedures, cursors, and transaction examples
  • How to create a stored procedure in MySQL and add records in a loop
  • Detailed explanation of the entry-level use of MySql stored procedure parameters
  • mysql uses stored procedures to implement tree node acquisition method

<<:  Detailed steps for building, running, publishing, and obtaining a Docker image for the first time

>>:  Steps for Docker to build its own local image repository

Recommend

How to configure Nginx to support ipv6 under Linux system

1. Check whether the existing nginx supports ipv6...

Nginx configures the same domain name to support both http and https access

Nginx is configured with the same domain name, wh...

Ubuntu20.04 VNC installation and configuration implementation

VNC is a remote desktop protocol. Follow the inst...

Solution to Nginx session loss problem

In the path of using nginx as a reverse proxy tom...

Let’s take a look at JavaScript precompilation (summary)

JS running trilogy js running code is divided int...

Error mysql Table 'performance_schema...Solution

The test environment is set up with a mariadb 5.7...

SQL Practice Exercise: Online Mall Database Product Category Data Operation

Online shopping mall database-product category da...

Analysis of uniapp entry-level nvue climbing pit record

Table of contents Preface Hello World image Set b...

WeChat applet implements SMS login in action

Table of contents 1. Interface effect preview 2.u...

WeChat applet implements simple calculator function

This article shares the specific code for the WeC...

vue $set implements assignment of values ​​to array collection objects

Vue $set array collection object assignment In th...

CocosCreator general framework design resource management

Table of contents Problems with resource manageme...

HTML data submission post_PowerNode Java Academy

The HTTP request methods specified by the HTTP/1....

Detailed explanation of MySQL trigger trigger example

Table of contents What is a trigger Create a trig...