For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
Did you check to see if the syntax is valid already?
select trim( '01234567890', '0') x from dual,
Of course I checked it. Both Oracle 19c on https://livesql.oracle.com/ and Oracle 18c on https://dbfiddle.uk/?rdbms=oracle_18&fiddle=5294d7089cb5552ca2fdf89c62e9bab4 raises the ORA-00907: missing right parenthesis error.
ORA-00907: missing right parenthesis
I have added this proposal in the "ideas" section: https://community.oracle.com/tech/developers/discussion/4479151/add-an-optional-argument-c-after-a-comma-in-the-trim-s-function/p1?new=1
You said you compared different database engines: Oracle trim('0' from '01234567890') SQL Server trim('0' from '01234567890') MySQL trim('0' from '01234567890') Postgres trim('0' from '01234567890') All the above database engines have same TRIM syntax allowing leading, trailing or both (default): TRIM([LEADING | TRAILING | BOTH] [characters] FROM string) SY.
All the above database engines have same TRIM syntax allowing leading, trailing or both (default): TRIM([LEADING | TRAILING | BOTH] [characters] FROM string) Unfortunately, this syntax doesn't work in SQL Server. The select TRIM(LEADING '0' FROM '01230') query raises:
select TRIM(LEADING '0' FROM '01230')
Msg 102 Level 15 State 1 Line 1 Incorrect syntax near '0'.
See: https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=9f1441351df23937f8866eb4edb32bd9
Right, SQL Server TRIM trims on both sides only (we must use LTRIM/RTRIM to trim on one side). But what this has to do with your proposal? Neither of database engines you listed except SQLite supports TRIM('string','characters') syntax so it should be SQLite where TRIM([LEADING | TRAILING | BOTH] [characters] FROM string) syntax should be proposed. SY.
Neither of database engines you listed except SQLite supports TRIM('string','characters') syntax PostgreSQL also supports it (db<>fiddle). Additionally, as I said, it looks strange that Oracle database supports LTRIM(s, c) and RTRIM(s, c), but doesn't support: TRIM(s, c). it should be SQLite where TRIM([LEADING | TRAILING | BOTH] [characters] FROM string) syntax should be proposed. It should be proposed in SQLite and SQL Server. I have done it here and here.
LTRIM(s, c)
RTRIM(s, c)
TRIM(s, c)
It should be proposed in SQLite and SQL Server. I have done it here and here. Good, so when SQL Server & SQLite will implement it then TRIM([LEADING | TRAILING | BOTH] [characters] FROM string) will be fully portable. SY.