我想在循环结束时选择结果值。我正在简化原始问题的代码。状态可能是 1 或 0。这个循环是检查我的 SELECT UNIQUE 查询的结果中是否有任何“1”。如果“是”,那么我的函数的结果必须始终为 1(或 TRUE)。
DECLARE
CURSOR status_cursor is(SELECT UNIQUE status
FROM src_table st, bucket_table bt, many_table mt
WHERE st.id = bt.st_id
AND bt.mt_id = mt.id);
result BOOLEAN := FALSE;
BEGIN
FOR vals IN status_cursor
LOOP
IF vals.status = 1 THEN result := TRUE;
END IF;
END LOOP;
SELECT result FROM DUAL; <-- this line does not work see error msg.
END;
我收到此错误消息:
ORA-06550: line 20, column 9:
PLS-00382: expression is of wrong type
ORA-06550: line 20, column 2:
PLS-00428: an INTO clause is expected in this SELECT statement