Home » RDBMS Server » Server Utilities » sort in unix (SUN SOLARIS UNIX)
sort in unix [message #324072] Fri, 30 May 2008 11:09 Go to next message
pa1sas3
Messages: 27
Registered: June 2005
Junior Member
I have to sort the input file on 4th field in
descending order and use sql loader to put in a
oracle table.

Each field separated by '|'
First field is the primary key.

So, I can load one row per primary key with
max value in the 4th field, ignoring order on other
fields

I have to accomplish this in UNIX on a file
that looks like below:

This is how the input file looks like:

ABCD-0000-01|Philadelphia|200103|HONDA|BRND
ABCD-0000-01|Philadelphia|200103|TOYOTA|BRND
ABCD-0000-01|Philadelphia|200103|SUBARU|BRND
ABCD-0000-01|New York|200103|SUBARU|BRND
ABCD-0000-02|.... next row set details
ABCD-0000-02|...


required sort Output should be:

ABCD-0000-01|Philadelphia|200103|TOYOTA|BRND
ABCD-0000-01|Philadelphia|200103|SUBARU|BRND
ABCD-0000-01|New York|200103|SUBARU|BRND
ABCD-0000-01|Philadelphia|200103|HONDA|BRND


So that, when I use SQL LOADER, only the
first row in put in table and rejecting the other
3 rows (first field is primary key).

I tried this:

sort -t'|' +0 -1 -r +3 -4 input.dat -o output.dat

But it is sorting the full file. How to sort only
on the 4th field in descending ignoring the rest?

Thanks,
Pavan


Re: sort in unix [message #324074 is a reply to message #324072] Fri, 30 May 2008 11:30 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Use an external table.

Regards
Michel
Re: sort in unix [message #324076 is a reply to message #324072] Fri, 30 May 2008 11:39 Go to previous message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
>I have to sort the input file on 4th field in descending order and use sql loader to put in a oracle table.
No you don't!
The order of the rows in an RDBMS table are indeterminate.
Previous Topic: export and partitions (merged)
Next Topic: Import Parameter
Goto Forum:
  


Current Time: Fri Dec 09 22:58:33 CST 2016

Total time taken to generate the page: 0.10645 seconds