Formatting issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Formatting issue
# 1  
Old 11-02-2010
Error Formatting issue

I am running this query in a SQL session :
Code:
info_dtls=`sqlplus -s  /  <<eof
whenever sqlerror exit 1
set feedback off;
set verify off;
set echo off;
set heading off;
selecttrim(a.cont_title)||'","'||trim(b.cpgrp_desc)||
'","'||trim(to_char(to_date('20100930','yyyymmdd'),'MM/DD/YYYY'))||
'","'||trim(to_char(to_date('20100930','yyyymmdd'),'MM/DD/YYYY'))||
'","'||trim(to_char(b.cpgrp_dt_start,'MM/DD/YYYY'))||
'","'||trim(to_char(b.cpgrp_dt_end,'MM/DD/YYYY'))||
'","'||trim(to_char(to_date('20100930','yyyymmdd'),'MM/DD/YYYY'))||
'","'||trim(to_char(to_date('20100930','yyyymmdd'),'MM/DD/YYYY'))
fromcont a,cpgrp b
where cpgrp_cont_id_alias='10400112'
anda.cont_num=b.cont_num;
eof` >>  ${LOG_FILE_NAME} 2>&1

All the date values are variables in the original script (and those were alson formatted to delete leading space using the sed command)and I am hard coding here for the ease of understanding.
The problem is that, each time the info_dtls is printing the result like this
Code:
HOMJR Levaquin Prpritry ACUTE","HOMJR Levaquin Acute Only","04/01/2008","09/30/2 010","04/01/2008","09/30/2010",
"04/01/2008","06/30/2010

Please, look at the date marked in bold.Every time I am getting this issue.
If I am commenting out the previous line, the next date getting formatted like this. That means, every second date record fetch is getting formatted with an unwanted space.
Please provide me a solltion.
# 2  
Old 11-02-2010
Quote:
Originally Posted by mady135
If I am commenting out the previous line, the next date getting formatted like this. That means, every second date record fetch is getting formatted with an unwanted space.
Please provide me a solltion.
Just an observation: the additional blank char is at position 80, which is the default line width for many programs. Maybe it is just a "line break in disguise" and you could get rid of it by adjusting the "size" of the "virtual paper" you are printing to.

I am not sure which SQL client you are using, in Oracles SQLPLUS this is done with "SET LINESIZE <n>" (line width) and "SET PAGESIZE <n>" (number of lines before page break), IIRC.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with formatting

Hi, I am new to UNIX and need your help in formatting the below input command to the desire output Input: CREATE UNIQUE INDEX XPKTABLE1 ( COL1, COL2 ) ON TABLE_NM; Output: COMMENT ON TABLE DB_NM.TABLE_NM AS 'PK=,COL1,COL2; '; In... (14 Replies)
Discussion started by: varun2327
14 Replies

2. Shell Programming and Scripting

awk Script Output in Outlook Formatting Issue

When i execute the below shell script with 2 different Input files, for one of the data files (datafile1) my email message body in the outlook messes up and every thing comes up in one line. May i please know what i am doing wrong here or how to fix this? The only difference in data files is one is... (1 Reply)
Discussion started by: Ariean
1 Replies

3. Solaris

Syslog formatting issue

Hi, I am using log4j syslog appender to redirect the application logs to the solaris syslog. However, I am facing issue in formatting. It is not able to interpret new line characters and is printing \n as it is. Ex: Following is getting written into the syslog file. "\n \n File =... (4 Replies)
Discussion started by: Pra
4 Replies

4. Shell Programming and Scripting

Variable value substitution issue with awk command issue

Hi All, I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command. The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies

5. Windows & DOS: Issues & Discussions

email from *nix to Exchange - text formatting issue

Oracle Linux 5.6 x-86-64 (Red Hat derivitive) I have several shell scripts that capture output to a log file, then use that log file as the source of an email. For a very simplified example: echo Today is `date` >> $logfile /bin/mail -s "$subject" "$sendto" < $logfile (yes, $subject... (6 Replies)
Discussion started by: edstevens
6 Replies

6. Shell Programming and Scripting

Need assistance with a file issue and a terminal issue

Hello everyone, I'm in need of some assistance. I'm currently enrolled in an introductory UNIX shell programming course and, well halfway through the semester, we are receiving our first actual assignment. I've somewhat realized now that I've fallen behind, and I'm working to get caught up, but for... (1 Reply)
Discussion started by: MrMagoo22
1 Replies

7. Shell Programming and Scripting

Need solution to formatting issue

Hi All, I have written a grep command to grep the files containing Windows directories. I need to output this to a csv. So here is the code. OUTPUT_FILE="Sample-format.txt" ACT_OUTPUT_FILE="Sample-format.csv" grep -wHrnI --exclude=*.log ':\{1,2\}*\{1,2\}*'... (0 Replies)
Discussion started by: flamingo_l
0 Replies

8. Shell Programming and Scripting

formatting of df -k

Hello, I am developing a platform Independant tool that should work for all major unix flavors outlined in this forum(Solaris,Linux, AIX, HPUX, SCO,BSD) Therefore, in order to cover all types of user community, I have deliberately posted the same message on every forum. Please do not think... (9 Replies)
Discussion started by: darsh123
9 Replies

9. Shell Programming and Scripting

Space formatting issue in sed

How to remove any space around a specific charachter from a string using sed. for exmple : the string is like following str1='"name", "roll", "addr","job", "pay",' I need to remove all the spaces aronnd the commas. (8 Replies)
Discussion started by: mady135
8 Replies

10. Shell Programming and Scripting

Unix Arithmatic operation issue , datatype issue

Hi, I have a shell scripting. This will take 7 digit number in each line and add 7 digit number with next subsequent lines ( normal addition ). Eg: 0000001 0000220 0001235 0000022 0000023 ........... ......... ........ Like this i am having around 1500000 records. After adding... (23 Replies)
Discussion started by: thambi
23 Replies
Login or Register to Ask a Question