我有一个简单的SQL
脚本,它从一组表中返回一些数据,然后使用SQL*PLUS
将数据假脱机到csv。
脚本
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET TERMOUT OFF
SET HEADING OFF
SET TAB OFF
SET COLSEP ''
SET PAGESIZE 0
SET LINESIZE 32767
SET SQLBLANKLINE ON
SET TRIMSPOOL ON
SET TRIMS ON
SPOOL "C:\output.csv"
PROMPT "ID","PERSON","STUDY_ID","START_DATE","END_DATE","STATUS","PROGRESS_STATUS","AMOUNT","DATE","WITHDRAWN","SPARE"
SELECT
'"' || TRIM(ID) || '"'
||',"' || TRIM(PERSON) || '"'
||',"' || TRIM(STUDY_ID) || '"'
||',"' || TRIM(START_DATE) || '"'
||',"' || TRIM(END_DATE) || '"'
||',"' || TRIM(STATUS) || '"'
||',"' || TRIM(PROGRESS_STATUS) || '"'
||',"' || TRIM(AMOUNT) || '"'
||',"' || TRIM("DATE") || '"'
||',"' || TRIM(WITHDRAWN) || '"'
||',"' || TRIM(SPARE) || '"'
FROM
(
SELECT DISTINCT
A.ID,
A.PERSON,
A.STUDY_ID,
A.START_DATE,
A.END_DATE,
A.STATUS,
A.PROGRESS_STATUS,
A.AMOUNT,
"DATE",
A.WITHDRAWN,
TO_CHAR(COALESCE(A.ID, A.UI_ID) || '-' || COALESCE(B.PARENTID, B.ID)) AS SPARE
FROM SOME_TABLE A
LEFT JOIN SOME_OTHER_TABLE B ON B.ID = A.OTHER_ID
)
;
SPOOL OFF
SET FEEDBACK ON
SET VERIFY ON
SET TERMOUT ON
SET HEADING ON
SET TAB ON
SET SQLBLANKLINE OFF
SET TRIMSPOOL OFF
SET TRIMS OFF
SET ESCAPE OFF
我遇到的问题是我期望的csv文件的数据假脱机,但最后一列包含尾随空格。如何更改设置以删除尾随空格?