Question

  Asked: Jan 16 2008   3:12 PM GMT
  Asked by: Gilly400


File sort using qshell (this time with tags)


AS/400, Unix shells, Qshell, Database, DB2, Linux


Hi,

I'm trying to use qshell to do a sort of a (non-keyed) DB2 database file to remove duplicate records. I use the following command :-

sort -u /QSYS.LIB/$1.LIB/$2.FILE/$3.MBR | cat > /QSYS.LIB/$1.LIB/$2.FILE/$3.MBR

Where $1 = Library name, $2 = File name, $3 = Member name.

The command does a sort, removing duplicate records, and replaces the data in the original file with the sorted version of the data. This works fine when I try it with a small test file.
When I try this with a larger test file I get the following error in the qshell :-

001-0055 Error found creating file ....... Resource busy.

I'm running this on a machine with plenty of capacity, so I don't think that's an issue here. I think that the cat is starting to write the output before all the input has been read by the sort. Is there a nice way around this without sorting to another file first? Eventually I'll need to use this with some very large files.

I've already tried using a command substitution for the sort :-

$(sort -u /QSYS.LIB/$1.LIB/$2.FILE/$3.MBR) | cat > /QSYS.LIB/$1.LIB/$2.FILE/$3.MBR

But this didn't seem to make any difference.

Thanks in advance for any help,

Martin Gilbert.

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


Start this Answer and Earn your Knowledge Points!

By clicking "Create Answer", you can write the answer to this question that can be improved upon by your peers using the Answer Wiki.

Browse more Questions and Answers on AS/400, Database and Linux.

Looking for relevant AS/400 Whitepapers? Visit the Search400.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register