LOCATE SCALAR – Function returns first occurrence position in first string, second string:

Example 1:

SELECT LOCATE(‘I’,’MINE STRING’) FROM SYSIBM.SYDUMMY1

It returns value 2. Since first occurrence is 2.

Example 2:

SELECT LOCATE(‘I’,’MINE STRING’,3) FROM SYSIBM.SYDUMMY1

Now the answer will be 9. Since after third position it starts searching for ‘I’.

Read my post on DB2 functions.

Reference link here.

Fediverse reactions

Discover more from Srinimf

Subscribe now to keep reading and get access to the full archive.

Continue reading