Subject RE: [ib-support] Key of varying length problem
Author Leyne, Sean
Paul,

To my way of thinking, the solution is simple.

You always want to search for the postal zones for the postal code
patterns 'K', 'K9', 'K9J', 'K9J5', 'K9J5A' and 'K9J5A2', and then sort
them by descending postal postal code patterns.

In Firebird, the SELECT statement would be:

SELECT FIRST 1 POSTAL_ZONE
FROM POSTAL_CODES_ZONES
WHERE POSTAL_CODE_PATTERN IN( 'K', 'K9', 'K9J', 'K9J5', 'K9J5A',
'K9J5A2')
order by desc POSTAL_CODE_PATTERN


So, if you have zones defined for 'K', 'K9', and 'K9J5', the select
would return 'K9J5'.


Sean