Skip to Main Content

DevOps, CI/CD and Automation

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!

oci_bind_by_name and null values

752513Feb 9 2010 — edited Feb 11 2010
Hi, I'm developing a PHP application that helps users to execute SQL statements on an Oracle database. The idea behind the application is that the administrator enters a query with some bind variables, for example:

SELECT NAME, SALARY, DEPTNO FROM EMPLOYES WHERE SALARY > :salary AND DEPTNO = :deptno

After that the users are presented with a series of screens that allow them to select wich columns they want to see (in our case they could choose between NAME, SALARY and/or DEPTNO) and enter the values of the bind variables (in our case it would be salary and deptno). So far everything works like expected.

The problem I have is that if a null value is entered (say for example in deptno, we want to find out about the employees who belong to no department), the oci_bind_by_name() function wich I use in PHP to make the variable bindings doesn’t match any records. I understand that if you put something like "AND DEPTNO = NULL" the query should return no results. But, is there some way to make oci_bind_by_name() behave in a way similar as if the query would have been "AND DEPTNO IS NULL" when it receives a null value?.

Modifiying the query using PHP is an option I would like to avoid because I can't make any assumptions about the query as it is entered by an administrator.

Thank you for your time.
This post has been answered by Christopher Jones-Oracle on Feb 9 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 11 2010
Added on Feb 9 2010
2 comments
3,659 views