End of line in a string

Database

End of line in a string

Hi

 i have column in my table with formatted string data  like wise

 'TYPE de Question:      Plainte: Facturation'

'TYPE de Question: Products good?     Plainte: Facturation'

'TYPE de Question:  service ?    Plainte: Facturation'

'TYPE de Question:   report?   Plainte: Facturation'

i would like to fetch the data for each 'TYPE de Question:'  as mentioned below :

'TYPE de Question:   report? 

im trying to use the following query but the results are not correct :

SELECT

SUBSTR( TRIM(RC_DESCRLONG), POSITION('Type de Question:' IN RC_DESCRLONG), POSITION('Plainte:' IN RC_DESCRLONG) )

 FROM  Table_questions

WHERE INDEX(RC_DESCRLONG,'Type de Question:') > 0

 

any one please suggest me how to modify the query to get the result

4 REPLIES
N/A

Re: End of line in a string

Hi

position gives you the position when the string starts.

so you need something like

substring(x, position('yourstring' in x) + characters('yourstring'), position('nextstring' in x) - (position('yourstring' in x) + characters('yourstring')))

Re: End of line in a string

i tried with this its not working . Giving an empty space  whether we need to take end of line ?

N/A

Re: End of line in a string

so you mean that sometimes 'nextstring' does not exists? And you want to select the rest of the string in this case?

N/A

Re: End of line in a string

you would end up in someting like

substring(x, position('yourstring' in x) + characters('yourstring'), case when position('nextstring' in x) > 0 then position('nextstring' in x) else characters(x) end - (position('yourstring' in x) + characters('yourstring')))