所以,我一直试图让它发挥作用。我很沮丧,我无法弄清楚我做错了什么。我试图声明变量num并使用带有count的select into语句将值插入其中。之后我想做一个简单的if语句,它将根据结果运行更新或删除。我对Oracle Pl / SQL比较新,所以任何帮助都会非常感激。感谢
DECLARE
num number;
BEGIN
SELECT COUNT (*)
INTO num
FROM csteinkamp.gai
WHERE breed_ref_id = 455;
IF (num > 5)
THEN
UPDATE csteinkamp.gai
SET animal_nm = 'TEST'
WHERE breed_ref_id = 455;
ELSE
DELETE FROM csteinkamp.gai
WHERE breed_ref_id = 455;
END;
答案 0 :(得分:1)
if
以end if
;
DECLARE
num number;
BEGIN
SELECT COUNT (*)
INTO num
FROM csteinkamp.gai
WHERE breed_ref_id = 455;
IF (num > 5)
THEN
UPDATE csteinkamp.gai
SET animal_nm = 'TEST'
WHERE breed_ref_id = 455;
ELSE
DELETE FROM csteinkamp.gai
WHERE breed_ref_id = 455;
END IF; -- End if.
END; -- End of the program block.