mySql 存储过程与函数
过程
CREATE DEFINER=`root`@`%` PROCEDURE `clearDate_Jk`()
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DELETE FROM sys_dept WHERE create_time > '2023-12-31';
truncate table sys_file;
END
CREATE DEFINER=`root`@`%` PROCEDURE `getAssets`(
IN `companyId` BIGINT
)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
SELECT CAST(JSON_UNQUOTE(JSON_EXTRACT(a.infos,'$."总资产"')) AS DECIMAL(10, 2)) AS zzc
FROM bs_company_financial a WHERE del_flag =0 AND years = YEAR(CURDATE())
ORDER BY update_time LIMIT 1;
END
函数
CREATE DEFINER=`root`@`%` FUNCTION `tt`(
`Param1` INT
)
RETURNS decimal(10,0)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
declare num decimal default 0;
set num = Param1;
return num;
END
择善人而交,择善书而读,择善言而听,择善行而从。