Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sql query with bind variable NULL

ora_1978Sep 4 2021

create table null_test (eno number, ename varchar2(20), salary number);

insert into null_test values (1, 'Peter',1000);
insert into null_test values (null, 'john',null);
insert into null_test values (3, null,3000);

commit;

Query Required:

One single select query

select * from null_test where eno = :p_eno ; -- :p_eno when assigned NULL ,I want all three records to get displayed
select * from null_test where eno = :p_eno ; -- :p_eno when 1.I want all one record with eno 1 should get displayed

same for varchar2 fields ename

Regards,
Vinodh

This post has been answered by Jan Gorkow on Sep 4 2021
Jump to Answer
Comments
Post Details
Added on Sep 4 2021
5 comments
2,541 views