I have the below SQL and giving me expression errors.
I want to check if the record exists, If Exists, then I want to execute one sql and get column values, If not I want to execute another sql and get columns values.
How can I do this oracle ?
DECLARE
VALIDEXISTS NUMBER;
BEGIN
SELECT *
FROM table1
WHERE column1 IN ('Yes')
AND columns2 IN (
SELECT COUNT(column1) AS VALIDEXISTS
FROM table1
WHERE column1 IN ('Yes')
AND column2 NOT LIKE '%Yes%'
IF VALIDEXISTS = 0 THEN
SELECT column2
FROM table1
WHERE column1 IN ('Yes')
AND column2 NOT LIKE '%Yes%'
ELSE
SELECT column2
FROM table1
WHERE column1 IN ('Yes')
AND column2 NOT LIKE '%No%' END IF; )
END
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…