#Spool/Query executing with extra space.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers #Spool/Query executing with extra space.
# 1  
Old 04-15-2014
Wrench #Spool/Query executing with extra space.

Hello,

I have a requirement where i have to spool some data to a file. i have achived the desired target but m facing one issue. i have attached the script and the output.

i checked the data length in the table but it is only 45 for column 1.

can you tell me how to remove these extra spaces after the first column.
# 2  
Old 04-15-2014
I will suggest to use trim function in your sql query itself

trim(col_name)
Code:
trim(col_name)

---------- Post updated at 05:49 AM ---------- Previous update was at 05:44 AM ----------

Also try to fix your col length as below

Code:
rpad(substr(col_name,1,16),18,' ')

# 3  
Old 04-15-2014
Hello dodmis,

i have tried that already and still it is giving me same output, i was just wondering is there any set command which i have to use. Do u know any such command.

In my output i just want the string length of the output. ex

abcdefghi abcdef abcedf
abcde abcde abcde

the 3 spaces indicating the column one has ended.
# 4  
Old 04-15-2014
try with below options

Code:
set feedback off
set verify off
set termout off
set trimspool on
set linesize 500
set pages 0

for query

Code:
select rpad(substr(col_name,1,16),18,' ') from table_name

This User Gave Thanks to Makarand Dodmis For This Post:
# 5  
Old 04-15-2014
Thanku dod,

the rpad functn to replace the spaces worked, i just did some changes in the numbers.

thanks a lot.Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extra Space in output - remove

Hi All I am trying to perform the below operation -count=`cat abc.txt | wc -l` echo$count 5 Head=Start"$DATE"00000"$count"File echo $HEAD START15020300000 5File There is a space coming before 5 which is not needed . How to ignore that . (4 Replies)
Discussion started by: honey26
4 Replies

2. Shell Programming and Scripting

Query on executing awk using SSH

Hi All, Im trying to find the count of process running on remote server using SSH. Below command dosen't work. ssh -q user@host "ps -ef | grep "pattern" | grep -v 'grep' | awk '{print $2}'|wc -l" But below command works. ssh -q user@host "ps -ef | grep "pattern" | grep -v... (1 Reply)
Discussion started by: Girish19
1 Replies

3. Shell Programming and Scripting

[Solved] Howto remove extra space in the file

Hi Gurus, I have a file which contains some special char or space. when using cat -evt I can see the file as following: 0,"0000","abc/def aaa ... (6 Replies)
Discussion started by: ken6503
6 Replies

4. Shell Programming and Scripting

my shell now adds extra space at end of each line!

Hi, Since today, with csh or tcsh, if I do 'ls files* > list', every lines end with an extra space! What happenned? What can I do to go back when there was no extra space? If I change to bash, there's no extra space. Thanks, Patrick ---------- Post updated at 03:19 PM... (1 Reply)
Discussion started by: trogne
1 Replies

5. Shell Programming and Scripting

m4 adds extra space at top of file.

I have used m4 in the past to generate source code where aesthetics and space were of no consequence . Now I am using it to generate script and program templates . So here is an excerpt from my m4 file for producing a generic bash script: dnl `$Id$' define(`START_SCRIPT',`#!/bin/bash... (8 Replies)
Discussion started by: Bubnoff
8 Replies

6. Shell Programming and Scripting

extra space issue with awk

for diskname in $(lspv |awk '{print $1}') do lquerypv -h /dev/|awk '/'$diskname'/ { print ; exit }' done No output is returning from the loop. I think awk put an extra space to the command - lquerypv -h /dev/ so that the command is executed as i.e. lquerypv -h /dev/ hdisk230 with a space... (7 Replies)
Discussion started by: Daniel Gate
7 Replies

7. Programming

Single sql query to spool to multiple files

Is there anyway to spool my select statement into spool files of max 10000 records each? eg I have a select statement that will return 45000 records. A normal spool command will output the 45000 into just one spool file. How can I make sqlplus do this? 00001 - 10000 records --- spool... (3 Replies)
Discussion started by: Leion
3 Replies

8. Shell Programming and Scripting

To spool output from a database query

Hi all, I would want to spool file for a database query, however by using crontab, the file is not spooled. Below shows my script: ORACLE_HOME="/u01/oraprod/perpdb/10.1.0/db_1" OUTFILE="/tmp/invalid.out" FILE="$HOME/admin/scripts" $ORACLE_HOME/bin/sqlplus -s "/as sysdba"... (0 Replies)
Discussion started by: *Jess*
0 Replies

9. Shell Programming and Scripting

Script executing sql query

Hello, I have a sh script excuting a sql query through sqlplus. I am having trouble making my date equal to the date of the server time in the sql script. How can i call the server date from my query? Thanks (2 Replies)
Discussion started by: kingluke
2 Replies

10. UNIX for Dummies Questions & Answers

NOQUEUE: low on space ( have 0, SMTP-DAEMON needs 101 in /var/spool/mqueue)

hi, I'm in Solaris 2.8 env. When i'm trying to add a ftp user account , encountered "no space in disk" .. couldn't create any user. Then check the fs disk space with "df - k " and /var/adm/syslog .. got the below message. Jun 9 03:10:53 mail sendmail: NOQUEUE: low on space (have 0,... (10 Replies)
Discussion started by: Dolly
10 Replies
Login or Register to Ask a Question