This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 30th, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,260 Users
  • 2,269,776 Discussions
  • 7,916,824 Comments

Discussions

Add an optional argument c after a comma in the TRIM(s) function

iwis
iwis Member Posts: 12 Green Ribbon

Hi!

I compared string functions in 5 different RDBMS: PostgreSQL, MySQL, Oracle, SQL Server and SQLite, and also in the ANSI SQL Standard. There are large differences among different RDBMS, and I propose to reduce them a little bit.

Particularly, I propose to add an optional argument c after a comma in the TRIM(s) function (the space ' ' by default).

Explanation: We can now call the following functions in Oracle:

LTRIM(s [,c])
RTRIM(s [,c])
TRIM (s)

As you see, we can pass the argument c after the comma in the LTRIM and RTRIM functions, but not in the TRIM function, which is strange. For the TRIM function we have to use the SQL ANSI Standard syntax: TRIM(c FROM s). On the other hand, in PostgreSQL and SQLite calling TRIM(s, c) is possible. So this difference between different RDBMS and the difference in Oracle itself between the LTRIM/RTRIM(s [,c]) and TRIM(s) functions seem to be unjustified. Or maybe somebody knows a justification?

I also proposed this change: https://community.oracle.com/tech/developers/discussion/4477919/proposal-add-the-substring-alias-for-the-substr-function/.

The changes proposed by me for other RDBMS are listed here: https://github.com/iwis/SQL-notes/blob/master/Functions_proposed_changes.md

Sven W.Shanu Kuar
2 votes

Active · Last Updated

Comments