当前位置:网站首页>MySQL storage and custom functions
MySQL storage and custom functions
2022-06-26 07:05:00 【Rorschach379】
select col_name,
case when char_length(col_intro)>20 then
concat(left(col_intro,20),'.....')
else col_intro end
from tb_college;
drop function if exists truncate_string;
delimiter $
create function truncate_string(
content varchar(12000),
max_length int unsigned
)
returns varchar(12000) no sql
begin
declare result varchar(12000)default content;
if char_length(content)>max_length then
set result=concat(left(content,max_length),'.....');
end if;
return result;
end $
delimiter ;
select col_name,
truncate_string(col_intro,20)
from tb_college;
delimiter $
create procedure sp_upgrade_emp_sal()
begin
start transaction;
update tb_emp set sal=sal+100 where dno=10;
update tb_emp set sal=sal+200 where dno=20;
update tb_emp set sal=sal+300 where dno=30;
commit;
end$
delimiter ;
call sp_upgrade_emp_sal();
delimiter $
create procedure sp_get_avg_sal(
in dept_no int,
out avg_sal decimal(10,2)
)begin
select round(avg(sal),2) into avg_sal
from tb_emp where dno=dept_no;
end $
delimiter ;
call sp_get_avg_sal(10,@sal);
select @sal;
边栏推荐
- shell 输入验证仅限字母数字
- Market development status analysis and investment risk outlook report of China's battery industry 2022-2027
- China's Ni MH battery industry development overview analysis and investment trend forecast report 2022 Edition
- 一芯实现喷雾|WS2812驱动|按键触摸|LED显示|语音播报芯片等功能,简化加湿器产品设计
- STM32F1与STM32CubeIDE编程实例-热敏传感器驱动
- 海量日志采集工具——Flume
- SHOW语句用法补充
- Numpy learning challenge level 5 - create array
- Development trends and prospects of acrylamide crystallization market in the world and China 2022-2027
- oracle创建带返回值的存储过程并sql执行调用
猜你喜欢

Stm32f1 and stm32subeide programming example - thermal sensor driver

【图像检测】基于形态学实现图像目标尺寸测量系统附matlab代码

What is data mining?

How to publish function computing (FC) through cloud effect

LabVIEW Arduino tcp/ip remote smart home system (project part-5)

Mysql操作数据库

安装homebrew报错汇总

基于sanic的服务使用celery完成动态修改定时任务

Hudi compilation of data Lake architecture

3,3 '- di (3,4-dicarboxyphenoxy) -4,4' - diphenylethynylbiphenyldianhydride (bpebpda) / porphyrin 2dcofs (H2P COF, ZNP COF and cup COF) supplied by Qiyue
随机推荐
Typescript: use polymorphism instead of switch and other conditional statements
SHOW语句用法补充
[image fusion] multimodal medical image fusion based on coupled feature learning with matlab code
同花顺究竟如何开户,网上开户是否安全么?
一文深入底层分析Redis对象结构
【图像融合】基于梯度能量、局部能量、 PCA三种融合规则实现MRI-CT图像融合附matlab代码
Golang源码包集合
Analysis report on market demand and investment competitiveness of China's cyclohexanone industry (2022 Edition)
Numpy learning challenge level 4 - numpy array attribute
快速找到优质对象的5种渠道,赶紧收藏少走弯路
5,10,15,20-tetra (4-bromophenyl) porphyrin (h2tppbr4) /5.2.15,10,15,20-tetra [4-[(3-aminophenyl) ethynyl] phenyl] porphyrin (tapepp) Qiyue porphyrin reagent
I have been testing at Tencent for several years
Pytorch builds CNN LSTM hybrid model to realize multivariable and multi step time series forecasting (load forecasting)
一项听起来大胆,并且非常牛逼的操作——复刻一个 Netflix
[image detection] image saliency detection based on ITTI model with matlab code
Shell input validation alphanumeric only
【图像融合】基于耦合特征学习的多模式医学图像融合附matlab代码
Service interface test guide
shell 输入验证仅限字母数字
NumPy学习挑战第一关-NumPy的下载与安装