I'm using Delphi 7
ok...i will explain you complete scenario where it is not working in my application.
1. I have query1
select col1, col2 from #table1 --temp table
union
select col1 AS '', col2 AS 'xyz' from table2
this retuns me
col1 col2
----- -----
xyz -- here col1 is empty string
1 a
2 b
2. Now i have one more query 'query2'
select col1, col2 from table3
this returns me
col1 col2
---- -----
1 abc
NULL xyz
3 bcd
3. Now i want to locate in query2
my actual locate statement is as below
Code: Select all
query2.locate('col1', query1.fieldbyname('col1').AsString), []);
after your suggetion i have changed to
Code: Select all
query2.locate('col1', query1.fieldbyname('col1').Value), []);
Note: query1.fieldbyname('col1').AsString/Value is having empty string value.
In both the ways it is not working and locate is returning False.
I have modified my query1 to select NULL instead of empty string in union. But still it did not work. So i started debugging the code and found the problem with the below statement
Code: Select all
Result := (Values[i] = nil) and Data.GetNull(FieldDesc.FieldNo, RecBuf)
and replaced the above statement with
Code: Select all
Res := TMemData(Data).CompareFieldValue(Values[i], Types[i], FieldDesc, RecBuf, Options);
Result := (Res = 0);
So please let me know how to solve this issue if my suggestion to you is not worth.