Forum OpenACS Development: trim

Collapse
1: trim
Posted by luis unda on
Good morning,

I am trying to trim all 10 right characters next to the user id.

By using:

RTRIM(PORTAL.OPC_SURVEY_SCORES.RESPONDENT, '0123456789') = PORTAL.WWCTX_API.GET_USER

I get UNDALD as out output allowing the comparison to work fine (UNDALD = UNDALD)

However,

If user 'EFCUST1" is logged in, I get

EFCUST

Therefore comparison does not work (EFCUST != EFCUST1)

I have searched everywhere and I do not seem to find a way to strip all 10 numeric numbers from the string. The string will always have these 10 numeric characters at the end.

Any assistance is appreciated.

This are the strings...

UNDALD0000000025

EFCUST10000000026

Collapse
2: Re: trim (response to 1)
Posted by Brian Fenton on
Hi Luis,

In Oracle, just use the RTRIM function. For example:

select rtrim('abcd123','0123456789') as trimmed from dual;

TRIMMED
------------
abcd

I guess in your case you could do:
RTRIM(PORTAL.OPC_SURVEY_SCORES.RESPONDENT, '0123456789') = RTRIM(PORTAL.WWCTX_API.GET_USER, '0123456789')

Hope this helps
Brian

Collapse
3: Re: trim (response to 1)
Posted by Christian Eva on
Can you not prepare the variable in tcl? i.e:

string range $s 0 end-10

Collapse
4: Re: trim (response to 1)
Posted by Nis Jørgensen on
I may be missing the point, but can't you just use

SUBSTR(PORTAL.OPC_SURVEY_SCORES.RESPONDENT, 1, LENGTH(PORTAL.OPC_SURVEY_SCORES.RESPONDENT) - 10)

IE ignore the fact that the characters you want to remove are digits, and just remove ten of them.

/Nis