MySql存储过程问题!急求大神赐教!
发布网友
发布时间:2022-04-15 04:43
我来回答
共2个回答
热心网友
时间:2022-04-15 06:12
create PROCEDURE tendersbidsystem.Pro_UpdateTender_STATE(IN L_ID VARCHAR(64))
BEGIN
DECLARE L_TEN_ID VARCHAR(64);
SELECT INVITE_ID INTO L_TEN_ID FROM TENDERS_INVITETENDERS WHERE ID = L_ID;
--这个地方确保这个select into语句查询出来的结果只有0或者1条记录,多于1条会报错
UPDATE TENDERS_INVITETENDERS SET BIDTYPE = '0' WHERE ID = L_ID;
IF ((SELECT count(ID) FROM TENDERS_INVITETENDERS WHERE INVITE_ID = L_TEN_ID AND BIDTYPE = '1') = 0) --这个地方加上一个括号
THEN
UPDATE TENDERS_BIDINVITINGUNI SET BIDSTART = '2' WHERE ID = L_TEN_ID;
END IF;
END
追问加上括号和不加一样的,我发现问题是,执行不了then里面的更新语句。我直接写这个更新语句都更新不了。mysql权限问题么? mysql全是我都配置了。实在找不到什么原因。。。。
热心网友
时间:2022-04-15 07:30
IF (SELECT count(ID)
FROM
TENDERS_INVITETENDERS
WHERE
INVITE_ID = L_TEN_ID
AND BIDTYPE = '1') = 0
if后面是赋值语句,改成IF (SELECT count(ID)
FROM
TENDERS_INVITETENDERS
WHERE
INVITE_ID = L_TEN_ID
AND BIDTYPE = '1') == 0追问双等报错。编译都通不过