book
Article ID: 113763
calendar_today
Updated On:
Issue/Introduction
CA Datacom SQL Version 15.1 provides a new character scalar function LOCATE_IN_STRING.
Resolution
Datacom SQL scalar function LOCATE_IN_STRING is a flexible and powerful string search scalar function which has options to:
1. Search for the "nth" occurrence
2. Search backwards
LOCATE_IN_STRING(source, search, start, instance, units)
For example:
Find the domain name in a column named URL in the table named TRANSACTIONS
SELECT URL, SUBSTR(URL, LOCATE_IN_STRING(URL, '.', -1, 2) + 1,
LOCATE_IN_STRING(URL, '.', -1, 1) -
LOCATE_IN_STRING(URL, '.', -1, 2) - 1) AS DOMAIN
FROM TRANSACTIONS;
The result:
URL DOMAIN
------------------- --------
HTTP:\\WWW.CA.COM CA