DELIMITER $$
USE `test_2jzy`$$
DROP PROCEDURE IF EXISTS `PROC_PLATFORM_SET_VALUE`$$
CREATE DEFINER=`root`@`%` PROCEDURE `PROC_PLATFORM_SET_VALUE`(
IN c_year VARCHAR ( 20 ),
IN c_index_id INTEGER,
IN c_value DECIMAL ( 16, 2 )
)
BEGIN
DECLARE index_pid INT;
SELECT pid INTO index_pid FROM perf_index_source WHERE id=c_index_id;
IF index_pid = 0 THEN
UPDATE perf_index_fill_detail t
SET t.fill_item_value=c_value
WHERE t.fill_id IN (SELECT id FROM perf_index_fill WHERE index_id=c_index_id AND STATUS=0 AND YEAR=c_year) AND source_id=c_index_id;
ELSEIF index_pid != 0 THEN
UPDATE perf_index_fill_detail t
SET t.fill_item_value=c_value
WHERE t.fill_id IN (SELECT id FROM perf_index_fill WHERE index_id=index_pid AND STATUS=0 AND YEAR=c_year) AND source_id=c_index_id;
END IF;
COMMIT;
END$$
DELIMITER ;
MySQL存储过程示例
最新推荐文章于 2023-10-12 13:55:36 发布