How to remove blank spaces from SQL*Plus query?

China☆狼群 提交于 2019-12-02 07:29:21

问题


My query below being called from sqlplus is returning lot of spaces in the end of each value, how can I remove it?

See example below: * I substituted the values with x

x            ,x                                                                                                                          
                                                                                                           ,x                             ,x                          ,x,x
x

My query is:

set linesize 1000
set trimspool on
set trimout on
set pagesize 0
set colsep ,
set feedback off

spool /result.csv

SELECT process_id,
  x1,
  x2,
  x3,
  x4,
  x5,
  x6,
  x
FROM x
WHERE x IN ('x');

回答1:


The simplest way is to concatenate the columns with the commas in between, rather than using colsep:

select process_id
    ||','|| x1
    ||','|| x2
...

Note that you only have the comma in the concatenation strong, not between the columns. You end up with a single column in the reult.



来源:https://stackoverflow.com/questions/17390755/how-to-remove-blank-spaces-from-sqlplus-query

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!