- 17.9K All Categories
- 3.4K Industry Applications
- 3.3K Intelligent Advisor
- 62 Insurance
- 536K On-Premises Infrastructure
- 138.2K Analytics Software
- 38.6K Application Development Software
- 5.7K Cloud Platform
- 109.4K Database Software
- 17.5K Enterprise Manager
- 8.8K Hardware
- 71.1K Infrastructure Software
- 105.2K Integration
- 41.5K Security Software
Allow to set negative substr length: SUBSTR(text,position,-length)
SUBSTR(text,1,-2) => "abcdef"
This would fetch a part from a string that is a little less than the original string.
The suggestion would be a shortcut (and hopefully one with a higher performance) to
SUBSTR(text, 1, LENGTH(text)-2))
The advantage is that this eliminates the need to write "text" - which could be a complex expression - twice.
We already can select a few characters from the end of the string using a negative position.
SUBSTR(text,-2) => "gh"
returns the last two chars from a text. However currently there is no quick way to fetch the first part.
The suggestion would complete this.
-- Edit --
added 4th parameter length_mode: needed so that existing code still produces NULL for negative lengths. See further comments in this thread.