当前位置:网站首页>MySQL create stored procedure ------ [hy000][1418] this function has none of deterministic, no SQL
MySQL create stored procedure ------ [hy000][1418] this function has none of deterministic, no SQL
2022-07-28 02:14:00 【kjshuan】
# You have to set Otherwise an error
set @@global.log_bin_trust_function_creators = 1;
# Five tables joint query And call the stored procedure
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;
# Delete stored procedure
drop function if exists cal_addr;
# Create stored procedure
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;
# Calling stored procedure
select cal_addr(20,' Specific address ');
#mybaits One to many Use 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>
边栏推荐
- MySQL高可用和主从同步
- Go learn 02 basic knowledge
- 软件测试面试题:你认为做好测试用例设计工作的关键是什么?
- Under the new retail format, retail e-commerce RPA helps reshape growth
- Vxe table/grid cell grouping and merging
- Software testing interview question: what types of software testing are you familiar with?
- 考研数学一元微分学证明题常见题型方法
- Comparison between hardware SPI and software analog SPI rate
- 样本不均衡-入门0
- Linux Installation mysql8.0.29 detailed tutorial
猜你喜欢

A lock faster than read-write lock. Don't get to know it quickly

Hcip day 12 notes

Under the new retail format, retail e-commerce RPA helps reshape growth

【愚公系列】2022年07月 Go教学课程 019-循环结构之for

华为APP UI自动化测试岗面试真题,真实面试经历。

Linux Installation mysql8.0.29 detailed tutorial

Leveraging the blue ocean of household appliances consumption with "digital channels", the dealer online system enables enterprises to further their business

Fluorite network, difficult to be a "lone brave"

JS what situations can't use json Parse, json.stringify deep copy and a better deep copy method

Go learning 01
随机推荐
Product interpretation - Design and distributed expansion of metersphere UI test module
Packet capturing wizard netcapture app packet capturing tutorial "complete"
Principle and implementation of cross entropy
53: Chapter 5: develop admin management service: 6: develop [admin administrator exit login, interface]; (one point: when we want to modify a value with a certain coding method, the new value should b
A letter to the user of qubu drawing bed
轻量版项目管理系统
结构伪类选择器—查找单个—查找多个—nth-of-type和伪元素
Appium 点击操作梳理
新零售业态下,零售电商RPA助力重塑增长
Software test interview question: please introduce the meaning of various test types in detail?
Principle and implementation of focal loss
C # using ABP warehouse to access the database error record set
Starfish Os X MetaBell战略合作,元宇宙商业生态更进一步
Promise从入门到精通(第3章 自定义(手写)Promise)
【Star项目】小帽飞机大战(六)
Interviewer: are you sure redis is a single threaded process?
Gbase 8C backup control function (IV)
go 学习02 基础知识
Data security and privacy computing summit - provable security: Learning
Hcip 13th day notes