šis, savukārt, nestrādā
create table test (id number(12), val varchar2(150));
insert into test(id, val) values (1, 'a');
insert into test(id, val) values (2, 'b');
insert into test(id, val) values (3, 'c');
insert into test(id, val) values (4, 'd');
insert into test(id, val) values (5, 'e');
DECLARE
v_statement VARCHAR2(1000);
v_result test%ROWTYPE;
v1 NUMBER;
v2 NUMBER;
v3 NUMBER;
BEGIN
v_statement := '
SELECT *
FROM test
WHERE (( :1 = 1
AND :2 = 2
)
OR :1 is null
)
AND rownum = 1';
EXECUTE IMMEDIATE v_statement
INTO v_result
USING v1 -- 1
,v2 -- 2
;
END;
/