File Format issue: Output of sqlplus


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers File Format issue: Output of sqlplus
# 1  
Old 10-19-2007
Error File Format issue: Output of sqlplus

Hi,

I am using a query like below in my shell script :

{
{
echo "set echo off"
echo "set head off"
echo "whenever sqlerror exit -1;
select NUMBER ||','||
FNAME ||','||
LOC ||','||
NUM ||','||
DESC ||','||
ID ||','||
INC ||','||
to_char(start_date,'dd-mm-yyyy') ||','||
to_char(end_date,'dd-mm-yyyy')
from emp_details
where .....
} | sqlplus -s testuser/testpass@testdb > EmpDetails.txt
}


As I need a comma separated file.

When the file is created, a sample lines looks like below:

2514,MY_TEST_NAME_IS,351,23728929,THIS_IS_A_TEST VALUEQ,47265,Y,01-04-2008,01-01
-2027

As you can see there is an extra carriage return coming after "01-01" and the "-2027" is going to the next line. This is happening with all the outout lines. Any data after a particular length is going to the next line.
How can I remove this formatting issue?

Thanks
Deepak
# 2  
Old 10-19-2007
Set Lines

Hi Deepak

The parameter you are looking for is the SET LINESIZE. It sets the number of characters as page width of the query results.

In you example, put this line after 'echo "set head off"':

echo "SET LINESIZE 300"

Regards,

Er
# 3  
Old 10-25-2007
Hi Er,

It worked Smilie Thanks for the help.

Deepak
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sqlplus code format

Hi, I have some questions about sqlplus running from bash. I am still new and learning. I have the code shown below: echo "exit" | sqlplus... (10 Replies)
Discussion started by: mohca2020
10 Replies

2. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

3. Shell Programming and Scripting

Sqlplus error - sqlplus -s <login/password@dbname> : No such file or directory

i am using bash shell Whenever i declare an array, and then using sqlplus, i am getting sqlplus error and return code 127. IFS="," declare -a Arr=($Variable1); SQLPLUS=sqlplus -s "${DBUSER}"/"${DBPASS}"@"${DBASE} echo "set head off ; " > ${SQLCMD} echo "set PAGESIZE 0 ;" >> ${SQLCMD}... (6 Replies)
Discussion started by: arghadeep adity
6 Replies

4. Shell Programming and Scripting

File format issue

Hi All, In unix is there any command to format the file in exact order.I have a file which there is no order in the fileds, I need to order it. Its a dat file wrong format TDEAIG36533827CB1210004241 EUR20130610BL1300351 refers to CB|CCI|A|A|C|R|T 246.76 ... (1 Reply)
Discussion started by: nag_sathi
1 Replies

5. UNIX and Linux Applications

Please help: Oracle gqsql or sqlplus output format like mysql

On psql select titolo,lingua from titolo where titolo ~* 'brivid'; titolo | lingua ------- + ------ Brivido | 1 On Sqlplus/gqsql SQL> select titolo,genere,anno,lingua from titolo where titolo like '%rivid%'; TITOLO... (6 Replies)
Discussion started by: Linusolaradm1
6 Replies

6. Shell Programming and Scripting

Format output issue

Dear Friends, Need your help. $cat input.txt TITLE Date:01-01-2011 Day: Friday Details Particulares Qty $ $ $ $ $ $more test.sh cat input.txt | while read line do echo "${line}" done $ $ (5 Replies)
Discussion started by: anushree.a
5 Replies

7. Shell Programming and Scripting

"links -dump" output format issue

Hi All, I tried searching a lot about this but to no avail. I have a HTML file. I used links -dump file_page.html > text_html.txt What the above command gave me was a filtered text from the HTML file with tags removed. Now, the the output from the above command looked something like this:... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

8. Shell Programming and Scripting

Format the output from sqlplus while writing to log file.

Hi I have developed bash script to connect to database and execute .sql files. I am logging some statements in to log file using echo. While logging I am adding the date in front of the log statements which makes sense. I am unable to add date in front of output from the sqlplus and sqlldr,... (8 Replies)
Discussion started by: murtymvvs
8 Replies

9. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

10. Solaris

Duplex Script - output format issue.

Hi Gurus, I had downloaded the below script from the net and used it to get the Link and duplex settings in my Sun servers. In all except one(Sol-5.10 on X86) i am getting output format like below: root: /var/ADMIN/bin/speed_duplex.sh Interface Speed Duplex --------- ... (2 Replies)
Discussion started by: Hari_Ganesh
2 Replies
Login or Register to Ask a Question