From: Dmitry A. <fd...@ua...> - 2004-03-25 12:09:32
|
Hello firebird-net-provider, [vb.net] _command.CommandText = "SELECT ID FROM EMPLOYES WHERE (BIRTHDAY=@B1 OR (BIRTHDAY IS NULL AND @B2 IS NULL))" _command.Parameters.Add("@ID", 1) _command.Parameters.Add("@B1", DBNull.Value) _command.Parameters.Add("@B2", DBNull.Value) Dim __id As Integer = _command.ExecuteScalar() and in execution gets exception: Data type unknown all right, because fbserver unknown type of @B2 parameter (it's he strange feautre of fbserver). but if rewrite on this: _command.CommandText = "SELECT ID FROM EMPLOYES WHERE " & _ "BIRTHDAY=@B1 OR " & _ "(BIRTHDAY IS NULL AND COALESCE(@B2, CAST(NULL AS DATE)) IS NULL)" all work :) When field is not null we may generate whereClausule2 template (as pk field). But when field nullable -- you generate whereClausule1, but this incorrect (when parameter not null -- in result set returned records and equal parameter value and field IS NULL. it's incorrect. and as result we got spare record). whereClausule1 = "(({0} IS NULL) OR ({0} = ?))"; whereClausule2 = "({0} = ?)"; In SqlClient use template ({0}=? OR ({0} IS NULL AND ? IS NULL)), but it's not work on fbserver. But if we work on firebird 1.5 we can release correct work thru, for example COALESCE keyword. When all be works fine! (May be CASE works too, but need 3 params, but not 2). I think that in server this feature will else long, but we already can get correct work, if using coalesce keyword, on FB1.5 at least once! -- Best regards, Dmitry mailto:fd...@ua... |
From:
<car...@te...> - 2004-03-25 12:41:09
|
Hello: > In SqlClient use template ({0}=? OR ({0} IS NULL AND ? IS NULL)), > but it's not work on fbserver. But if we work on firebird 1.5 we > can release correct work thru, for example COALESCE keyword. When > all be works fine! (May be CASE works too, but need 3 params, but > not 2). > > I think that in server this feature will else long, but we already > can get correct work, if using coalesce keyword, on FB1.5 at least > once! Hummmmmmmm ... not sure about what to do !! :) I think i can do a change do the generation of the where clausule using coalesce ( have you reviewed how the use of coalesce affects the query plan ?? maybe it have no effect ... i will try to check it ) for 1.5+ and using Pk fields only on all other versions ( 1.0.x and Interbase 6 ) Opinions ????? -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From: Dmitry A. <fd...@ua...> - 2004-03-25 14:33:04
|
Hello Carlos, Thursday, March 25, 2004, 2:41:01 PM, you wrote: CGÁ> I think i can do a change do the generation of the where clausule using CGÁ> coalesce ( have you reviewed how the use of coalesce affects the query CGÁ> plan ?? maybe it have no effect ... i will try to check it ) for 1.5+ CGÁ> and using Pk fields only on all other versions ( 1.0.x and Interbase 6 ) Hummmmmm... I think that this will render the negative influence upon building plan, but as it were there was not -- must work pravilino. better NATURAL plan, than incorrect result. And i'm don't know true... COALESCE its unsupported 1.0.x and Interbase 6? Or supported?!?! If not supported -- it's may be realised as feature for Firebird 1.5! CGÁ> Opinions ????? Is it my opinion! ;) -- Best regards, Dmitry mailto:fd...@ua... |
From:
<car...@te...> - 2004-03-25 14:35:39
|
Hello: > And i'm don't know true... COALESCE its unsupported 1.0.x and > Interbase 6? Or supported?!?! If not supported -- it's may be > realised as feature for Firebird 1.5! It's new in 1.5 -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From: Dmitry A. <fd...@ua...> - 2004-03-25 14:50:32
|
Hello Carlos, Thursday, March 25, 2004, 4:35:30 PM, you wrote: CGÁ> Hello: >> And i'm don't know true... COALESCE its unsupported 1.0.x and >> Interbase 6? Or supported?!?! If not supported -- it's may be >> realised as feature for Firebird 1.5! CGÁ> It's new in 1.5 Hummmmm... this in general interests anyone except me?!?!?! :))) 2Carlos: you to do work for this feature? :) -- Best regards, Dmitry mailto:fd...@ua... |
From:
<car...@te...> - 2004-03-25 15:07:06
|
Hello: > Carlos: you to do work for this feature? :) Yes i only need to decide how i'm going to fix it :) Huumm what about this?? : SELECT EMP_NO FROM EMPLOYEE WHERE (HIRE_DATE=@B1 OR (HIRE_DATE IS NULL AND @B2 = CAST(NULL AS DATE))) -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From: Dmitry A. <fd...@ua...> - 2004-03-25 15:56:09
|
Hello Carlos, Thursday, March 25, 2004, 5:06:59 PM, you wrote: CGÁ> Hello: >> Carlos: you to do work for this feature? :) CGÁ> Yes i only need to decide how i'm going to fix it :) CGÁ> Huumm what about this?? : CGÁ> SELECT EMP_NO FROM EMPLOYEE WHERE (HIRE_DATE=@B1 OR (HIRE_DATE IS NULL CGÁ> AND @B2 = CAST(NULL AS DATE))) Hmmmm... no, it's don't work, because @B2 = CAST(NULL AS DATE))) NULL = NULL --> NULL (false), no match comparison ^^^ binary operator for NULL arguments result always NULL. in this may use only IS NULL check, but in this construction parameter can't be used... :) COALESCE... ;))))))) -- Best regards, Dmitry mailto:fd...@ua... |
From:
<car...@te...> - 2004-03-25 16:40:57
|
Hello: > Hmmmm... no, it's don't work, because > @B2 = CAST(NULL AS DATE))) > NULL = NULL --> NULL (false), no match comparison > ^^^ binary operator for NULL arguments result always NULL. > in this may use only IS NULL check, but in this construction > parameter can't be used... :) COALESCE... ;))))))) > Ok with COALESCE ;), i will try to do the changes as soon as possible ( probably next week, i want to release beta 1 this weekend ) -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From:
<car...@te...> - 2004-04-07 17:30:58
|
Hello: > COALESCE... ;))))))) Sorry for the delay :P I think we have two solutions for this: 1. Check server version and use COALESCE when possible (i will try to retrieve the server version after connect) 2. Use always PK Fields only for in the where clausule Opinions ?? -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From: Dmitry A. <fd...@ua...> - 2004-04-08 09:20:38
|
Hello Carlos, Wednesday, April 7, 2004, 8:30:56 PM, you wrote: CGÁ> Sorry for the delay :P :P :D CGÁ> I think we have two solutions for this: CGÁ> 1. Check server version and use COALESCE when possible (i will try to CGÁ> retrieve the server version after connect) I think what it's solution is maximal correct. CGÁ> 2. Use always PK Fields only for in the where clausule For using PK Fields only -- we have CommandBuilderBehaivor property... :) CGÁ> Opinions ?? My opinion -- FbCommandBuilderEx %)))) -- Best regards, Dmitry mailto:fd...@ua... |