Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The concrete writing method of mysql stored procedure

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

I don't know if you have any knowledge about the specific writing of mysql stored procedures before, but I'm here to tell you a little bit about it today. If you are interested, let's take a look at the text. I believe you will gain something after reading the specific writing of mysql stored procedures.

You can use CREATE PROCEDURE statements to create stored procedures.

The syntax format of the database stored procedure is as follows:

CREATE PROCEDURE procedure name ([[IN | OUT | INOUT] parameter name data type [, [IN | OUT | INOUT] parameter name data type …]]) [features.] Process body DELIMITER / / CREATE PROCEDURE myproc (OUT s int) BEGIN SELECT COUNT (*) INTO s FROM students; END / / DELIMITER

Example: create a simple stored procedure

-Procedure structure for `proc_ adder`-DROP PROCEDURE IF EXISTS `proc_ adder`; DELIMITER;; CREATE DEFINER= `root` @ `localhost`PROCEDURE `proc_ adder` (IN an int, IN b int, OUT sum int) BEGIN # Routine body goes here... DECLARE c int; if an is null then set a = 0; end if; if b is null then set b = 0; end if;set sum = a + b

Execute the above storage results to verify that they are correct, as shown in the following figure

Set @ baked 5 witch call proc_adder (2meme BJM); select @ s as sum

After reading this article on the specific writing of mysql stored procedures, what do you think? If you want to know more about it, you can continue to follow our industry information section.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report