Locate Nearest Problem
Locate Nearest Problem
i get the problem with locate nearest...
pls see my code at below:
Database Structure:
# Create Database [Test], If not exist.
CREATE DATABASE IF NOT EXISTS Test;
# Use Database [Test]
USE Test;
# 1. Vehical Master File
CREATE TABLE IF NOT EXISTS Vehicle (
Registration VARCHAR(20) NOT NULL,
OwnerName VARCHAR(50) NOT NULL,
Make VARCHAR(30),
Model VARCHAR(30),
PRIMARY KEY (Registration)
);
# Insert Data.........
INSERT INTO Vehicle VALUES('MK--110', 'KEN', 'TOYOTA', '1.6A');
INSERT INTO Vehicle VALUES('MK--119', 'PETTY', 'KIA', '1.6A');
INSERT INTO Vehicle VALUES('MK-1184M-12', 'LOU', 'FORD', '1.6A');
Test.pas:
procedure TForm1.Button1Click(Sender: TObject);
begin
MyTable1.LocateEx('Registration', 'MK-1184M-11', [lxNearest]);
end;
Problem:
The cursor goto MK--119, no MK-1184M-11
Pls advise, Thanks
pls see my code at below:
Database Structure:
# Create Database [Test], If not exist.
CREATE DATABASE IF NOT EXISTS Test;
# Use Database [Test]
USE Test;
# 1. Vehical Master File
CREATE TABLE IF NOT EXISTS Vehicle (
Registration VARCHAR(20) NOT NULL,
OwnerName VARCHAR(50) NOT NULL,
Make VARCHAR(30),
Model VARCHAR(30),
PRIMARY KEY (Registration)
);
# Insert Data.........
INSERT INTO Vehicle VALUES('MK--110', 'KEN', 'TOYOTA', '1.6A');
INSERT INTO Vehicle VALUES('MK--119', 'PETTY', 'KIA', '1.6A');
INSERT INTO Vehicle VALUES('MK-1184M-12', 'LOU', 'FORD', '1.6A');
Test.pas:
procedure TForm1.Button1Click(Sender: TObject);
begin
MyTable1.LocateEx('Registration', 'MK-1184M-11', [lxNearest]);
end;
Problem:
The cursor goto MK--119, no MK-1184M-11
Pls advise, Thanks
locate for mysql
I find that locateex does not produce the right result when the index has a key with a '-' in it before the desired key. It seems to stop at the first key with a '-' before the desired key. Thus locating 'Rock County' stops at 'R-M' even when 'Rock County' exists.