mysql创建一个函数

mysql创建一个函数,第1张

DELIMITER $$

CREATE FUNCTION `ChkInsert`(in_pk int) returns int

begin

declare _count int

declare _returnValue int

set _count = 0

select count(列1) into _count from 你的表 where 列1 = in_pk

if _count >0 then

set _returnValue = 2

else

insert into 你的表 ( 列1 ) values ( in_pk )

set _returnValue = 0

end if

return _returnValue

end $$

create function 函数名称(参数列表)

reurns 返回值类型

函数体

执行的方法很简单:

加载

** create function <函数名称>returns {string|real|integer}

** soname <你定义的动态库位置>

释放!

** drop function <函数名称>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11931073.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存