当前位置:网站首页>mysql创建存储过程---------[HY000][1418] This function has none of DETERMINISTIC, NO SQL
mysql创建存储过程---------[HY000][1418] This function has none of DETERMINISTIC, NO SQL
2022-07-28 00:40:00 【kjshuan】
#必须设置 不然报错
set @@global.log_bin_trust_function_creators = 1;
#五表联查 并且调用存储过程
select e.empid,e.empname,e.telephone,e.entertime,e.gender,e.age,
j.jobname,d.depname,
c.cardno,c.gettime,c.outdate,c.cardtype,c.photo,
c2.comname, cal_addr(c2.addrid,c2.address) detailaddr
from employees e
inner join jobs j on e.jobid=j.jobid
inner join departments d on e.depid = d.depid
inner join company c2 on d.comid = c2.comid
left join credentials c on e.empid = c.empid;
set @@global.log_bin_trust_function_creators = 1;
#删除存储过程
drop function if exists cal_addr;
#创建存储过程
create function cal_addr(addr int,compaddr varchar(200))
returns varchar(300)
begin
declare cityinfo varchar(50) default "";
select concat( a1.addrname,a2.addrname,a3.addrname) into cityinfo
from address a1,address a2,address a3
where a3.addrid=addr and a3.subaddr=a2.addrid and a2.subaddr=a1.addrid;
set cityinfo=concat(cityinfo,compaddr);
return cityinfo;
end;
#调用存储过程
select cal_addr(20,'具体地址');
#mybaits 一对多 使用resultMap
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC
"-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.kgc.towercrane.tchr.mapper.QueryHrMapper">
<resultMap id="emp-emp" type="EmpPage">
<result property="currentPage" column="currentpage"/>
<result property="rowPage" column="rowPage"/>
<collection property="datas"
column="{c=currentPage,r=rowPage}"
ofType="EmployeesVO"
select="findEmpByPage"/>
</resultMap>
<select id="findEmp" parameterType="EmpPage" resultMap="emp-emp">
<![CDATA[
select ceil(count(*)/#{rowPage}) total,#{rowPage} rowPage,#{currentPage} currentPage,
if(#{currentPage}<ceil(count(*)/#{rowPage}),#{currentPage}+1,#{currentPage}) next,
if(#{currentPage}=1,#{currentPage},#{currentPage}-1) previous,
if(#{currentPage}<ceil(count(*)/#{rowPage}),1,0) hasNext,
if(#{currentPage}=1,0,1) hasPrevious from employees
]]>
</select>
<select id="findEmpByPage" resultType="EmployeesVO">
select e.empid,e.empname,e.telephone,e.entertime,e.gender,e.age,
j.jobname,d.depname,
c.cardno,c.gettime,c.outdate,c.cardtype,c.photo,
c2.comname, cal_addr(c2.addrid,c2.address) detailaddr
from employees e
inner join jobs j on e.jobid=j.jobid
inner join departments d on e.depid = d.depid
inner join company c2 on d.comid = c2.comid
left join credentials c on e.empid = c.empid limit ${(c-1)*r},#{r}
</select>
</mapper>
边栏推荐
猜你喜欢

After learning the loop, I came across the problem of writing factorial of N, which caused a series of problems, including some common pitfalls for beginners, and how to simplify the code

Hcip day 12 notes

Traversal and properties of binary trees

Starfish Os X MetaBell战略合作,元宇宙商业生态更进一步

In it, there is a million talent gap, and the salary rises, but it is not capped

处理数据 给数据换名字

一种比读写锁更快的锁,还不赶紧认识一下

Linux Installation mysql8.0.29 detailed tutorial

Solution of digital commerce cloud supply chain centralized purchase management system: centralized purchase system management mode, digital control of enterprise materials

如何评估研发人员效能?软件工程师报告帮你看见每个人的贡献
随机推荐
Redis design specification
Unreal ue4.27 switchboard porting engine process
微信小程序实现动态横向步骤条的两种方式
测试/开发程序员的级别“陷阱“,级别不是衡量单维度的能力......
Talk to ye Yanxiu, an atlassian certification expert: where should Chinese users go when atlassian products enter the post server era?
They are all talking about Devops. Do you really understand it?
What devices does devicexplorer OPC server support? This article has listed
Use of classes in typescript
Five basic data structures of redis
处理数据 给数据换名字
day7
小米网站主页面大模块——小模块+导航(浮动案例)
Real time data warehouse: meituan's real-time data warehouse construction practice
How to evaluate the effectiveness of R & D personnel? Software Engineer reports help you see everyone's contribution
2022软件测试技能 Robotframework + SeleniumLibrary + Jenkins web关键字驱动自动化实战教程
ArcGIS:加载历史遥感影像
Machine learning how to achieve epidemic visualization -- epidemic data analysis and prediction practice
样本不均衡-入门0
Domain Driven Design -- Terminology
Gbase 8C general file access function