[I've come back to look at this thread that I filed a while ago...] On Wed, Feb 13, 2002 at 01:04:15PM -0800, Michael Peppler wrote: > Hi, > > The DBI docs state the following: > > Binding an `undef' (NULL) to the placeholder will not > select rows which have a NULL `product_code'! Refer to the > SQL manual for your database engine or any SQL book for > the reasons for this. To explicitly select NULLs you have > to say "`WHERE product_code IS NULL'" and to make that > general you have to say: > > ... WHERE (product_code = ? OR (? IS NULL AND product_code IS NULL)) > > and bind the same value to both placeholders. > > I understand the reasoning for this, and why it's the only way for > database servers that don't understand "= null". > > However this syntax does NOT work with DBD::Sybase because of the way > OpenClient handles the prepare. The issue is the "? is null" part: > neither the Sybase client libs, nor the server can determine what > datatype the placeholder is supposed to be, and I see no way to add a > directive to tell the server that this item is of the same type as > "product_code".
Why do you have to? If "neither the Sybase client libs, nor the server can determine what datatype the placeholder is supposed to be" can't you just bind it as a varchar or similar? Are there any other valid sql statements that have this problem? (Like using placeholders as parameters for functions that take different kind of datatypes.) > Sybase, on the other hand, understands "= null". What do "the Sybase client libs, nor the server" say about the datatype of this placeholder: "? = null" > I'll document this in the DBD::Sybase docs, but I just wanted to flag > the fact that the method documented in the DBI docs is unfortunately > not portable to Sybase (and *probably* not to ODBC when using a > Sybase). I don't know if ODBC w/MS-SQL handles this correctly or not. What wording have you added to the docs? [I'm trying to work out what to say in the DBI docs.] Tim.