I have a zipcode stored in a text field (string) and would like to select only the last 3 digits of the value in my select statement. is this possible? Is there a standard way of doing this so that the SQL is interchangeable accross databases? I will be using it in production on Oracle, but i test on Interbase (yes, yes, i know, two totally diff DBs, but thats what i am doing)
thanks for any help you can offer
Assuming the zipcodes all have the same length, you can use
substr
.If they don't have the same length, you have to do similar things with the
strlen
function.Interbase does not have a built-in substring function, but it does have a
UDF
(user defined function) calledSUBSTR
inlib_udf.dll
that works like this:You declare the UDF like this:
Oracle does have a built-in substr function that you use like this:
--jeroen