I have parameter :prmtr and what I wanted is to use a select statement based on the parameter input.
I tried this:
if :prmtr= \'A\' then
You may try something like this with a CURSOR
variable and PRINT
command. This works in SQL* plus and in SQL developer or TOAD when run as script.
VARIABLE prmtr VARCHAR2
EXEC :PRMTR := 'A' -- SET values of parameter
VARIABLE x refcursor -- a cursor variable
DECLARE
BEGIN
IF :PRMTR = 'A' THEN
OPEN :x FOR
SELECT *
FROM employees;
ELSE
OPEN :x FOR
SELECT *
FROM departments;
END IF;
END;
/
PRINT x -- gives you the result of the query.