Hi. I keep getting errors - This is the syntax directly from ESRI:
|TRIM(BOTH | LEADING | TRAILING trim_character FROM string_exp)|
I have tried:
TRIM(LEADING '0' FROM "TRAIL_NO")
TRIM(LEADING '0' FROM '0%')
both of these error with
|Invalid SQL syntax [ORA-00920: invalid relational operator]|
I have also tried many other iterations and have received errors such as missing expression, etc.
What is the correct syntax to remove leading 0s from a text field? Please help, thanks!!
Also odd - one of the errors showed [STATE_ID = 27] and I do not have a state id field in my attribute table.
Have you found a resolution to this? I am only finding the same syntax documentation as you noted above. I have not found any working examples of how to use TRIM as all instances of the question I've found in the Esri Community pages have been left unanswered.
Hello Justine, I think the problem with your query is that it needs a SQL operator like (=, <, >,...). Your TRIM expression looks fine. Here's an example that'll return all rows with an empty OWNER_NAME after the leading and trailing white space is removed:
TRIM(BOTH ' ' FROM OWNER_NAME) = ''
However, if you wanted to recalculate a field and remove the leading '0' you could use python like this:
def removezero(field): if (field == "0"): return field[1:] else: return(field)