开发者

In Oracle, how do you use two different functions on the same column?

开发者 https://www.devze.com 2023-03-19 07:26 出处:网络
I am trying to use two different string functions (initcap and trim) on one column and I would like it to display only the one column with both functions 开发者_Python百科applied.In general how do you

I am trying to use two different string functions (initcap and trim) on one column and I would like it to display only the one column with both functions 开发者_Python百科applied. In general how do you use two or more functions on a single column?


In general, you can nest function calls within function calls, evaluated innermost to outermost:

SELECT INITCAP(TRIM(column)) FROM your_table;

As long as each nested function returns a value of a compatible type, you should be able to apply this to any functions.

For example:

SELECT '|' || INITCAP(TRIM('  abc def ghi  jklmn   ')) || '|' str
  FROM dual;

Results in:

STR
--------------------
|Abc Def Ghi  Jklmn|

Note I concatenated the pipe symbol to illustrate the TRIM of the string.

More to the point here:

SELECT '|' || INITCAP(TRIM('.' FROM '... abc def ghi  jklmn...')) || '|' str FROM dual;

Gives me:

STR
----------------------
| Abc Def Ghi  Jklmn|
0

精彩评论

暂无评论...
验证码 换一张
取 消