如果写这个
DECLARE res INTEGER;
DECLARE loop_res INTEGER;
BEGIN
SELECT 0 INTO loop_res;
FOR i IN 1..5 LOOP
SELECT loop_res + i INTO loop_res;
END LOOP;
SELECT
case
WHEN some_variable < 3
THEN --some result
WHEN some_variable >= 3
THEN loop_res
END
INTO res;
这行得通,但无论如何这里都会执行 LOOP 语句,对吗?
只有在 if 的情况下才可以执行 LOOP 语句WHEN some_variable >= 3
?
我在尝试 :
SELECT
case
WHEN some_variable < 3
THEN --some result
WHEN some_variable >= 3
THEN
FOR i IN 1..5 LOOP
SELECT loop_res + i INTO loop_res;
END LOOP;
loop_res
END
INTO res;
给出错误syntax error at or near "FOR" at character ...