I am writing an Oracle stored procedure to return the results of a database query. If the query does not produce any results, a second query must be run in its place.
In SQL Server, I can accomplish this using something similar to the following:
INSERT INTO @TableVar
SELECT <joinQuery1>;
IF (SELECT COUNT(*) FROM @TableVar) > 0
BEGIN
SELECT * FROM @TableVar; -- returns <joinQuery1>
END
ELSE
SELECT <joinQuery2>; --returns <joinQuery2>
END
However, I can not wrap my head around how to accomplish the same task in Oracle.