sqlPlus output with new line character


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users sqlPlus output with new line character
# 1  
Old 03-07-2008
Question sqlPlus output with new line character

Hi,

I have a script which calls a sqlplus command and i'm saving the output in a variable.

Code:
Z=`sqlplus -s $TC_ORACLE_USER/$TC_ORACLE_PASSWORD@$TC_CONNECT_STRING <<eof
set echo off
set head off
set serveroutput on;
set feedback off;
select description from period
where trunc(sysdate) between startdate and enddate
and periodtypeid = 'month';
exit;
eof`

echo "'$Z'"

When i check the variable the output seems like below (with a new line character)

Quote:
'
March 2008'
I dont need the new line character in my SQL output. What i need is like below:

Quote:
'March 2008'
Is there any way to achieve that. If so please let me know.

Thanks in advance!
# 2  
Old 03-08-2008
You need to set pagesize to 0:

Code:
$ printf "set head off feed off\nselect sysdate from dual;"|sqlplus -s '/ as sysdba'

09-MAR-07
$ printf "set pages 0 feed off\nselect sysdate from dual;"|sqlplus -s '/ as sysdba'
09-MAR-07
$

# 3  
Old 03-08-2008
Works like a charm !! Thanks !!

Quote:
Hi,

Thanks for the solution. Although I havent tried it yet but it seems this is what i was looking for. I'll try it and will let you knw if it doesnt work.

Thanks again!

Last edited by decci_7; 03-10-2008 at 03:13 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Line break in sqlplus output through ksh script

Hi, I am new to shell script programming. I have written a ksh script to run the sql File placed in server directory and spool the output in destination directory. Below Command: $ORACLE_HOME/bin/sqlplus -s $ora_uid @$sqlfile_loc$testquery.sql > $opfiledirectory It is generating the output... (6 Replies)
Discussion started by: Sumit Arora
6 Replies

2. Shell Programming and Scripting

Sqlplus function output to bash

Hi, I would like to have the output from an Oracle procedure be captured into a bash variable, then emailed to me when it runs on the cron daily as such: ~~~~~bash script~~~~~~~~~~~ #!/bin/bash shellvar=`sqlplus -s <<EOF execute test(); commit; exit; EOF` echo $shellvar mail -s "email... (1 Reply)
Discussion started by: inlinesidekick
1 Replies

3. Solaris

sqlplus output from ksh.

Hi All, I have the below simple script. It runs just fine by itself when I manually invoke it. But once I put it in the crontab with entry: * * * * * /users/myuser/test.ksh >> /users/myuser/log/test.txt" It does NOT print the returned value ($REMAIN) from the DB!? The result in the... (3 Replies)
Discussion started by: steve701
3 Replies

4. Shell Programming and Scripting

Log sqlplus output from Shell

UNIX Gods, I'll be running this script from CRON. I need to log the status of each of the six sqlplus calls into a file when this job is kicked off. Any suggestions? Thanks in advance. #!/bin/ksh export USAGE="USAGE: `basename $0` -e <DBUSER> <DBPASSWD> <TNSNAME>" if ; then ... (2 Replies)
Discussion started by: WhoDatWhoDer
2 Replies

5. Shell Programming and Scripting

store sqlplus output in variable

hi how can i store sqlplus output to a variable in sh script (not bash) Thanks MM (1 Reply)
Discussion started by: murtymvvs
1 Replies

6. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

7. Shell Programming and Scripting

Formatting Oracle sqlplus output

a job extracts orcle data into unix as flat file. a single record breaks into two record in unix flat file. This is the case only for 6 records out of 60 lack records. (its not single record in two line. but its single record into record. ie., \n come into picture) can you tell me what... (6 Replies)
Discussion started by: Gopal_Engg
6 Replies

8. Shell Programming and Scripting

output arguments from a sqlplus

Hi. I need to output a 4 queries result into another application using result=`sqlplus -s ${3}/${4}@${2} << EOF ... query1 query2 query3 query4 .... echo "$metrics1" and returning those individual values into another app. (query1 and 3compute one value, query 2 and 4 compute 4... (3 Replies)
Discussion started by: shell_zen
3 Replies

9. UNIX for Dummies Questions & Answers

Getting output parameter in sqlplus

I need to get the output parameter from a stored procedure in sql plus using shell script. Can anyone help me please ... (1 Reply)
Discussion started by: risshanth
1 Replies

10. UNIX for Dummies Questions & Answers

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 ||','|| ... (2 Replies)
Discussion started by: deepakgang
2 Replies
Login or Register to Ask a Question