SQL*Plus (MOSC)

MOSC Banner

Getting rid of additional spaces while spooling the data to text file.

edited Aug 10, 2016 11:32AM in SQL*Plus (MOSC) 6 commentsAnswered

Hi,

I am facing an issue where in I am trying to spool result returned by a select query to a file.

What I want is the folloing result:

$> cat testfile.txt

name1|age1|id1|

name2|age2|id2|

.....

nameN|ageN|idN|

But what I am getting:

name1                                                                              |age1                                                      |id1                              |

name2                                                                              |age2                                                      |id2                              |

.....

nameN                                                                              |ageN                                                      |idN                              |

Take a look at my script:( this is shell script.)

CONNECT $ORA_USER/$ORA_PWD@$ORACLE_SID

SET TERMOUT OFF

set colsep '|'

set linesize 3000

set pagesize  0

set heading off

SET TRIMSPOOL ON

spool $file_path;

$sql_query;

Please suggest me some ways I can achieve the desired output. However I have the option to go for sed command in shell script to remove all white spaces. But I am looking if something can be done in sqlplus side. And also note that Select col1||'|'||col2||'|'||col3 from ....

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center