当前位置:网站首页>Stored procedure learning notes
Stored procedure learning notes
2022-07-01 06:35:00 【Small dollar】
function
Self defined
stored procedure
Relative to the function, there can be no return value , Stored procedure stored function is stored in mysql On the server of , And pre compiled
stored procedure :
No parameters
Only in type ( No return with parameters )
Only out type ( No parameters return )
Yes in and out Parameters of type ( There are parameters and returns )
If you don't specify it when you create it, the default is in type
stored procedure
characteristics: Indicate the constraints in the stored procedure
language sql: Indicates whether the result of the stored procedure behavior is certain
sql security: Indicate the permissions of the stored procedure
delimit $ Replace the seal to indicate the end
Creation of stored procedures
delimiter //
CREATE PROCEDURE show_max_salary()
BEGIN
SELECT MAX(salary) FROM emp;
END //
delimiter ;
Calls to stored procedures
CALL show_max_salary
Create calls with parameters in stored procedures
elimiter //
CREATE PROCEDURE show_min_salary(OUT ms DOUBLE)
BEGIN
SELECT min(salary) INTO ms
FROM emp;
END //
delimit ;
call show_min_salary(@ms);
SELECT @ms
Call of stored procedure with parameters 2
delimiter //
CREATE procedure show_some_one_salary (IN empname VARCHAR(20))
BEGIN
SELECT salary FROM emp WHERE last_name = empname;
END //
delimiter ;
Call mode 1
call show_some_one_salary(“abel”)
Call mode 2
set @empname = ‘Abel’;
call show_some_one_salary(@empname);
Creation and call of stored procedure with parameters 3
delimiter //
CREATE PROCEDURE show_someone_salary(IN empname varchar(20),OUT empsalary DECIMAL(10,2))
BEGIN
SELECT salary INTO empsalary FROM emp WHERE last_name = empname;
END //
delimiter ;
SET @empname = "abel";
call show_someone_salary (@empname,@empsalary);
SELECT @empsalary
stored procedure inout3
delimiter $
CREATE procedure show_mgr_name(inout empname VARCHAR(25))
BEGIN
SELECT last_name INTO empname FROM emp
WHERE employee_id =
(SELECT manager_id FROM emp WHERE last_name = empname);
end $
delimiter ;
set @empname := "abel";
call show_mgr_name(@empname);
SELECT @empname
ps: When using stored procedures, it is difficult to troubleshoot errors because they cannot be debugged
边栏推荐
- Postgraduate entrance examination directory link
- 绕圆旋转动画组件,拿过来直接用
- Redis安装到Windows系统上的详细步骤
- C语言课设学生考勤系统(大作业)
- DSBridge
- 华福证券开户是安全可靠的么?怎么开华福证券账户
- [network security tool] what is the use of USB control software
- Find the original array for the inverse logarithm
- [automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
- C语言课设图书信息管理系统(大作业)
猜你喜欢
[unity shader amplify shader editor (ASE) Chapter 9]
问题:OfficeException: failed to start and connect(二)
[network security tool] what is the use of USB control software
[ManageEngine Zhuohao] what is network operation and maintenance management and what is the use of network operation and maintenance platform
VS2019如何永久配置本地OpenCV4.5.5使用
B-tree series
产品学习(二)——竞品分析
【微信小程序低代码开发】二,在实操中化解小程序的代码组成
Record MySQL troubleshooting caused by disk sector damage
阿里OSS Postman Invalid according to Policy: Policy Condition failed: [“starts-with“, “$key“, “test/“]
随机推荐
3. Disabling copy construction
C language course design student information management system (big homework)
How does the port scanning tool help enterprises?
C language course is provided with employee information management system (large operation)
在支付宝上买基金安全吗?哪里可以买基金
Docker 安装部署Redis
Grain Mall - environment (p1-p27)
如果我在广州,到哪里开户比较好?究竟网上开户是否安全么?
请求模块(requests)
软件工程领域的名词描述
Postgraduate entrance examination directory link
ManageEngine Zhuohao helps you comply with ISO 20000 standard (IV)
JMM details
JSON module
B-tree series
[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
RestTemplate使用
码力十足学量化|如何在财务报告寻找合适的财务公告
Software engineering review
C#如何打印输出原版数组