Home » Open Source » Programming Interfaces » Problems with Bind Variables and Prepared Statements (Oracle 10Gr2, Linux)
Problems with Bind Variables and Prepared Statements [message #447486] Mon, 15 March 2010 07:42 Go to previous message
Rudolphk
Messages: 7
Registered: March 2009
Location: Washington D.C.
Junior Member

I think the following issue occurs in all languages which support the prepared statement (I am currently using Ruby with the OCI8 libraries)

The issue I am having is with creating prepared statements to query the surrogate key of a table based on an alternate-key definition.

example:

select id from mytable where mycol1 = :1 and mycol2 = :2

The problem is that mycol2 in this example may be NULL. When mycol2 is null, Oracle does not return the proper result set.

select id from mytable where mycol = 'some value' and mycol2 is null (works)

select id from mytable where mycol = 'some value' and mycol2 = NULL
(does not work)

Is there an elegant coding solution to this problem? I have a workaround, but its not great. I am trying to construct generic code which can look at a table's definition and dynamically create code to perform table lookups.
 
Read Message
Read Message
Read Message
Previous Topic: help me overcome this error in jdbcodbc
Next Topic: show incorrect result
Goto Forum:
  


Current Time: Tue Dec 10 00:18:40 CST 2019