-1

i have 1 SQL file as below:

set pages 0
set head off
set feedback off
set echo off
set termout off
set wrap off
spool /osp/tmp/bangdd/dumpthe.dump
select a.SERNUM ||','|| b.AMOUNT||','|| b.TOPPF||','|| a.RFPROF from voucher a, SCRATCHP b where b.ri=a.RFPROF and a.sernum='000010263549703';
spool off

the out put file with cat -A as below.

linus> cat -A dumpthe.dump
000010263549703,20000,020,6 $

you can see, there are many space from 6 to $. it make file size is lager than normal. i can use sed command to remove space in the file but i want to know if any option in Oracle SQL can help that?

when i change my query as below

set pages 0
set head off
set feedback off
set echo off
set termout off
set wrap off
spool /osp/tmp/bangdd/dumpthe.dump
select a.SERNUM ||','|| b.AMOUNT||','|| b.TOPPF||','|| a.RFPROF || ',' from voucher a, SCRATCHP b where b.ri=a.RFPROF and a.sernum='000010263549703';
spool off

the result same as below:

linus> cat -A dumpthe.dump
000010263549703,20000,020,6, $
2
  • 4
    SQL*Plus has a TRIMSPOOL setting that may solve your problem: SET TRIMS[POOL] [ON|OFF] Commented Nov 10, 2023 at 6:45
  • excillent. i can help to resolve my problem. Commented Nov 10, 2023 at 7:03

2 Answers 2

1

According to query you posted:

  • 000010263549703 is SERNUM column's value
  • 20000 is AMOUNT
  • 020 is TOPF
  • 6 $ is RFPROF

There's no evidence that query concatenates $ at the end of the output string.

Therefore, you got exactly what you have in that column. Someone put bunch of spaces between 6 and $. Can you verify that by querying that column only?

If I'm right, and you want to get rid of spaces, replace them with an empty string, e.g.

select a.SERNUM ||','|| b.AMOUNT||','|| b.TOPPF||','|| 
--
replace(a.RFPROF, ' ', '') --> this
--
from voucher a, SCRATCHP b 
where b.ri=a.RFPROF and a.sernum='000010263549703';

If I'm wrong, please, post sample data that illustrate that problem so that we could try to recreate it and see what happens.

answered Nov 10, 2023 at 6:09
Sign up to request clarification or add additional context in comments.

5 Comments

RFPROF is 6 only. you see $ because i use cat -A. you will see where is end of line.
linus> cat -A dumpthe.dump 000010263549703,20000,020,6 $ nis101 linus> this is result with your query. if i change like that. set pages 0 set head off set feedback off set echo off set termout off spool /osp/tmp/bangdd/dumpthe.dump select a.SERNUM ||','|| b.AMOUNT||','|| b.TOPPF||','|| a.RFPROF || ',' from voucher a, SCRATCHP b where b.ri=a.RFPROF and a.sernum='000010263549703'; spool off the result same as below: linus> cat -A dumpthe.dump 000010263549703,20000,020,6, $
What is RFPROF column's datatype?
it is number. RFPROF NUMBER(18)
OK; I thought that it might be CHAR (which is then right-padded with spaces up to total column length). After all, it seems that it is TRIMSPOOL you need (as @p3consulting said). Note that - if line length was fixed (apparently, it is not) - SET LINESIZE might perform better.
1

after update "set trimspool off" to "set trimspool on". it can help.

set pages 0
set head off
set feedback off
set echo off
set termout off
set trimspool on
spool /osp/tmp/bangdd/dumpthe.dump
select a.SERNUM ||','|| b.AMOUNT||','|| b.TOPPF||','|| a.RFPROF || ',' from voucher a, SCRATCHP b where b.ri=a.RFPROF and a.sernum='000010263549703';
spool off
exit

result:

cat -A dumpthe.dump
000010263549703,20000,020,6,$
answered Nov 10, 2023 at 7:05

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.