cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

HANA FUNCTION LOCATE WRONG POSITION RESULT

dausto
Explorer
0 Kudos
66

Hello guys,
I'm in trouble with LOCATE function returning data on HANA Database (HANA v. 2.00.059.09...).

This is the query a run:
SELECT T0.U_ALD_VARIANTI
,LOCATE(T0.U_ALD_VARIANTI,'=') AS POS
,LOCATE(T0.U_ALD_VARIANTI,'=',-1) AS POSX
,LOCATE(T0.U_ALD_VARIANTI,'=',-2) AS POSY
FROM OITM T0 WHERE t0."ItemCode"='DISCOFERRO2A$CL.1_Fg.II75DIAM60'

And the scope is to find position of the first and second char '=' in the string 'CLRIF=CL.1;CLFIG=_Fg.II75;TGSEG=DIAM60'.
The positions are 6, 17 and 32 but as you can see in the image below, for second '=' in position 17 the function doesn't return me the correct position.
Catch 2025-05-19 alle 12.45.45.png

I believe that may be because of the underscore ( '_' ) in the string; probably LOCATE function use a search LIKE in the string.

Please, have you any suggestion or there is another function instead of LOCATE for obtaining the same find result?

Thank you in advance!

Accepted Solutions (0)

Answers (0)