Length for String in Locate?
Length for String in Locate?
Hi, is there a max length for the String in Locate?
I am using Sqlite-3, and a combination of String-items to give me a unique ID for some data. When I use Locate to find specific records, it sometimes doesn't work correctly, returning things not even close.
I am using
Date + Time + DataStr
The DataStr can often be 120-Characters or more in length and I am wondering if the Locate is not using the full string.
I can truncate the DataStr a little, but I still need it to be human-recognizable indicating what it is. The Time is formatted to the 100th of seconds to always make it unique.
Thank you.
I am using Sqlite-3, and a combination of String-items to give me a unique ID for some data. When I use Locate to find specific records, it sometimes doesn't work correctly, returning things not even close.
I am using
Date + Time + DataStr
The DataStr can often be 120-Characters or more in length and I am wondering if the Locate is not using the full string.
I can truncate the DataStr a little, but I still need it to be human-recognizable indicating what it is. The Time is formatted to the 100th of seconds to always make it unique.
Thank you.
Ubuntu 14.04-LTS, Acer i5, 6GB, 256GB-SSD, Lazarus 1.6.2, Zeos 7.1
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: Length for String in Locate?
Hello ToodleDoo,
hmmm - I didn't look into that code yet. But it might be that the comparison of strings is done based on the current locale settings in Windows and these might make some strings that are different look the same for comparisons. In some regions a and á are the same when sorting strings. Maybe that is something that you are seeing here?
With best regards,
Jan
hmmm - I didn't look into that code yet. But it might be that the comparison of strings is done based on the current locale settings in Windows and these might make some strings that are different look the same for comparisons. In some regions a and á are the same when sorting strings. Maybe that is something that you are seeing here?
With best regards,
Jan
Re: Length for String in Locate?
Thanks for the follow up, but all the text is Normal old US-English, not umlaut in sight.marsupilami wrote:In some regions a and á are the same when sorting strings.Jan
Ubuntu 14.04-LTS, Acer i5, 6GB, 256GB-SSD, Lazarus 1.6.2, Zeos 7.1
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: Length for String in Locate?
Ok, I just had to ask. Is there a chance for you to provide a small example where the problem occurs? A small project and a database or database script?
Re: Length for String in Locate?
I don't have a small copy of the database, but I changed the process to create a Hash of the data and save that.marsupilami wrote:Is there a chance for you to provide a small example where the problem occurs?
The hash is not working either. Here's some details. The Unique Hashes are being saved and recalled OK, just not being seen by Locate.
Code: Select all
uses
MD5;
function EmailHash(aStr : String) : String;
begin
Result:=MD5Print(MD5String(aStr));
end;
const
fldHash = 'zHash';
var
aHash : String;
begin
aHash:=EmailHash(memoIn.Lines.Text); // ac3f4687903bcd83f9e6903bc
if dm.tblEmails.Locate(fldHash,aHash,[loCaseInsensitive]) then
begin
LogEmails('DUP > '+aDate+' : '+aHash);
end else
begin
dm.tblEmails.Insert;
Code: Select all
// This never finds anything even if the Name exists
if dm.tblEmails.Locate(fldName,edName.Text,[loCaseInsensitive]) then
// but this does
tStr:=edName.Text;
if dm.tblEmails.Locate(fldName,tStr,[loCaseInsensitive]) then
I appreciate any help.
Ubuntu 14.04-LTS, Acer i5, 6GB, 256GB-SSD, Lazarus 1.6.2, Zeos 7.1
Re: Length for String in Locate?
I don't have a small copy of the database, but I changed the process to create a Hash of the data and save that.marsupilami wrote:Is there a chance for you to provide a small example where the problem occurs?
The hash is not working either. Here's some details. The Unique Hashes are being saved and recalled OK, just not being seen by Locate.
Code: Select all
uses
MD5;
function EmailHash(aStr : String) : String;
begin
Result:=MD5Print(MD5String(aStr));
end;
const
fldHash = 'zHash';
var
aHash : String;
begin
aHash:=EmailHash(memoIn.Lines.Text); // ac3f4687903bcd83f9e6903bc
if dm.tblEmails.Locate(fldHash,aHash,[loCaseInsensitive]) then
begin
LogEmails('DUP > '+aDate+' : '+aHash);
end else
begin
dm.tblEmails.Insert;
Code: Select all
// This never finds anything even if the Name exists
if dm.tblEmails.Locate(fldName,edName.Text,[loCaseInsensitive]) then
// but this does
tStr:=edName.Text;
if dm.tblEmails.Locate(fldName,tStr,[loCaseInsensitive]) then
I appreciate any help.
Ubuntu 14.04-LTS, Acer i5, 6GB, 256GB-SSD, Lazarus 1.6.2, Zeos 7.1
Re: Length for String in Locate?
Arrrggghgh -- STOP!!
It was someone working on the project. They had done... "// tblEmails.Filtered:=False;"
Sorry for the bother. Appreciate the time taken to look into it.
Oh and I am the only one working on the project!
It was someone working on the project. They had done... "// tblEmails.Filtered:=False;"
Sorry for the bother. Appreciate the time taken to look into it.
Oh and I am the only one working on the project!
Ubuntu 14.04-LTS, Acer i5, 6GB, 256GB-SSD, Lazarus 1.6.2, Zeos 7.1
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: Length for String in Locate?
Hello Hello ToodleDoo,
don't worry, things like that happen. Although I don't know why the Locate method shouldn't work when Filtered is false?
With best regards,
Jan
don't worry, things like that happen. Although I don't know why the Locate method shouldn't work when Filtered is false?
With best regards,
Jan