Subject Help
Author Tim Ledgerwood
I need to get the LONGEST matching string from a field in a data table.

Credit Cards have "bin numbers" - the first few digits on a credit card
determine what rules to apply to the card.

However, it's more sophisticated than that.

If you have an entry in the bin table of "4", for example, then all cards
that start with "4" will have those rules applied to them.

But say you have an entry in the table of "4556", as well as "4".

Then all cards that start with "4" will have those rules applied to them.

Except if you have cards that start with "45", "455" or "4556" - they will
have the rules under "4556".

At the moment, (using Delphi), I cycle through the table and cycle through
the BIN numbers in each table, using the following code :

if not dmStitch.tblPrefixList.Active then
dmStitch.tblPrefixList.Open;
dmStitch.tblPrefixList.First;
j := 0;
while not dmStitch.tblPrefixList.EOF do
begin
Temp := dmStitch.tblPrefixListPREFIX.AsString;
if Copy(APAN,1,Length(Temp)) = Copy(Temp,1,Length(Temp)) then
begin
i := Length(Temp);
if (i > j) then
begin
j := i;
LongestBIN := Temp;
end;
lFoundPrefix := true;
//Break;
end;
dmStitch.tblPrefixList.Next;
end;




Anyone know how I could do this in an SP?

Thanks in advance,

Tim


[Non-text portions of this message have been removed]