I'm trying to create a IF NOT EXISTS query in Oralce like this:
DECLARE
cnt NUMBER;
BEGIN
SELECT COUNT(*) INTO cnt FROM MY.MYTABLE
WHERE MYFIELD = 400;
IF (cnt = 0)
THEN
SELECT 'NO ROWS' AS FAIL FROM DUAL;
ELSE
SELECT 'SOME ROWS' AS PASS FROM DUAL;
END IF;
END;
but this fails for
ORA-06550: line 9, column 7:
PLS-00428: an INTO clause is expected in this SELECT statement
ORA-06550: line 11, column 7:
PLS-00428: an INTO clause is expected in this SELECT statement
Why, what is wrong with this query?
line 9, column 7andline 11, column 7