Order of data in Spool File


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Order of data in Spool File
# 1  
Old 09-07-2017
Order of data in Spool File

Hello,

I have a shell script through which I am executing .sql file and spooling the result of Query from .sql . I want to spool the result in ascending order. Is there any parameter to be set to print result in ascending or descending order.

Thanks in advance.
# 2  
Old 09-07-2017
Quote:
Originally Posted by Aparna.N
...
I have a shell script through which I am executing .sql file and spooling the result of Query from .sql . I want to spool the result in ascending order. Is there any parameter to be set to print result in ascending or descending order.
...
Add an "order by" clause to your query and that should sort the data the way you want.
This User Gave Thanks to durden_tyler For This Post:
# 3  
Old 09-07-2017
Thanks for reply. But I want to do it without adding 'order By' in Query. Is there any way to do it.
# 4  
Old 09-07-2017
You could use the sort command on the spool file, but there will be problems for example with headings.
The order by clause is the cleanest and easiest way and was designed to do what you ask for.
# 5  
Old 09-07-2017
Sorting within the SQL statement will be the most efficient, use the database sort order and respect values such as dates which in your output might look nice but are a nightmare to sort by the shell. Is there a reason you can't update the SQL? If the SQL is used by other processes, make a copy of it and change that instead.

Can you show us the SQL and some meaningful sample output from it? (in CODE tags, of course)



Thanks,
Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How order a data matrix using awk?

is it possible to order the following row clusters from ascending to descending. thanx in advance input 1 2 4 0 1 2 4 0 3 3 3 3 1 5 1 0 1 5 1 0 6 0 0 0 5 1 1 1... (4 Replies)
Discussion started by: quincyjones
4 Replies

2. Shell Programming and Scripting

Spool Data in a file

Hello, I am trying to spool data from database into a file on solaris through ksh. Data is getting fetched but the problem is record is getting split in to multiple lines. excerpt from sql is whenever sqlerror exit 1; set define on set echo off set feed off set head off set... (1 Reply)
Discussion started by: abhi1988sri
1 Replies

3. Shell Programming and Scripting

How to insert gaussian noise to a data with an order with awk?

Hello everybody, My problem is inserting gaussian noise to a file containing data, that is, add every single noise to the number after every 6 character. here is my data 0910 1 2048 32.38 40 20.88 28 35.53 9.62 0.00 MSDMP0 1.790MSDMS1 2.840KCTXP2 4.400KRCMP0 4.600BOZMP0 5.640BOZMS2... (26 Replies)
Discussion started by: miriammiriam
26 Replies

4. Shell Programming and Scripting

how to extract data from numbered files using linux in the numerical order-

Hi experts, I have a list of files containing forces as the only number as follows. Force1.txt Force2.txt Force3.txt Force4.txt Force5.txt . . . . . . . . . Force100.txt I want to put all the data(only a number ) in these forces files in the file with the same order like 1,2,3 ..100 .... (2 Replies)
Discussion started by: hamnsan
2 Replies

5. Shell Programming and Scripting

Spool file, only if data exists.

Hi All, I have one Question, that is it possible to check the spool output? What i mean to say is "spool the file only if data exists" I am trying to fetch data from a sql query, and want to generate a file, on a condition that the file should be generated, only if the output of the sql... (5 Replies)
Discussion started by: spiabhi
5 Replies

6. Shell Programming and Scripting

Help with sort data based on descending order problem

Input file 9.99331e-13 8.98451e-65 9.98418e-34 7.98319e-08 365592 111669 74942.9 0 Desired output 365592 111669 74942.9 7.98319e-08 1.99331e-13 6.98418e-34 (2 Replies)
Discussion started by: perl_beginner
2 Replies

7. Shell Programming and Scripting

Problem in spool file

Hi, Iam a newbie. When I give the below query at SQL prompt. SQL> select col1||'`ß`'||col2 from tablename where rownum<2; 1-J7WGX`ß`1-7OKC-23 Iam getting ß within appostropies...... If I remove appostropies and give the query it is throwing an error. If I give the same query in spool as... (1 Reply)
Discussion started by: kknayak
1 Replies

8. AIX

Spool data file

Dear Gurus, Tried searching for some clues in this forum but dont seem to be able to find my answer. :confused: Anyway i have a quick question: Today I have produced a messages generated from a application and placed them on the print queue. Before this I had stopped the printer queue, so... (2 Replies)
Discussion started by: lweegp
2 Replies

9. Shell Programming and Scripting

how to spool a unix file

hi, can anyone help me by saying how can i spool a unix file.. do we need to specify the pathname as such to spool the file .. right now, i tried giving like spool filename in the sql prompt.. but its not giving me the required output even if i can see that the command is being executed.. ... (2 Replies)
Discussion started by: kripssmart
2 Replies

10. Shell Programming and Scripting

AWK - printing certain fields when field order changes in data file

I'm hoping someone can help me on this. I have a data file that greatly simplified might look like this: sec;src;dst;proto 421;10.10.10.1;10.10.10.2;tcp 426;10.10.10.3;10.10.10.4;udp 442;10.10.10.5;10.10.10.6;tcp sec;src;fac;dst;proto 521;10.10.10.1;ab;10.10.10.2;tcp... (3 Replies)
Discussion started by: eric4
3 Replies
Login or Register to Ask a Question