records returned from sqlplus command coming in a single row [message #267487] |
Thu, 13 September 2007 08:15 |
ssunda6
Messages: 28 Registered: June 2007
|
Junior Member |
|
|
Hi All,
In an unix script, I am using sqlplus to retrieve data from an oracle table. The sql statement fetches 4 columns based on a condition and number of records returned might be 1000.
I am using the following code:
`sqlplus<<endofsql -S xxx@yyy/app1
set heading off;
select a,b,c,d from ap.log where b='abc';
exit;
endofsql`
I tried capturing the output returned from this command into a file and found that each record is not stored on a separate line but all records are being stored on a single line with each field separated by a space.
I want to process record by record.
Any inputs on this will be of great help.
Regards,
ssunda.
|
|
|
|
Re: records returned from sqlplus command coming in a single row [message #267502 is a reply to message #267487] |
Thu, 13 September 2007 09:46 |
ssunda6
Messages: 28 Registered: June 2007
|
Junior Member |
|
|
script:
echo `sqlplus<<endofsql -S xx@yy/ap11
set heading off;
select a,b,c,d from apps.xx where b='donothing';
exit;
endofsql` > temp.txt
$cat temp.txt
$Dev donothing 13-MAR-07 13-MAR-07 Dev donothing 14-MAR-07 14-MAR-07 LDev donothing 15-MAR-07 15-MAR-07 LDev donothing 17-MAR-07 17-MAR-07 LDev donothing 18-MAR-07 18-MAR-07
|
|
|
|
|
|
Re: records returned from sqlplus command coming in a single row [message #267733 is a reply to message #267487] |
Fri, 14 September 2007 07:51 |
ssunda6
Messages: 28 Registered: June 2007
|
Junior Member |
|
|
Michel, I executed your script. But output is in the following format:
Dev
donothing
13-MAR-07 13-MAR-07
LDev
donothing
15-MAR-07 15-MAR-07
LDev
donothing
17-MAR-07 17-MAR-07
First 2 columns of record are coming in 2 separate lines. 3rd and 4th columns came on single line.
For 3rd record, Between 1st and 2nd columns there is additional new line.
Regards,
ssunda.
|
|
|
|