根据错误提示可以看出:
set hzid = (select id from bip_ _in. oatobipzjhz where deptid = deptid and yearTime = yt and monthTime = mt);
你这个存在多个值
所以 建议修改成:
set hzid = (select id from bip_ _in. oatobipzjhz where deptid = deptid and yearTime = yt and monthTime = mt order by id desc limit 1);
还有一点要注意的时候
就是你设置的变量名:
set deptid = (select ID from org_ unit where PATH = v0 and STATUS = 1 and IS DELETED = 0 limit 1)
和
set hzid = (select id from bip_ _in. oatobipzjhz where deptid = deptid and yearTime = yt and monthTime = mt);
这里面的字段名相同了,这里如果你deptid = deptid 的意思是想字段=变量,那很容易出错的,所以这里尽量使用字段名和变量名不相同的