[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Modify record in flat file



Similar to some of the solutions mentioned, but if running in a Unix
environment I would use this tack:  write the detail records to a temp file,
then use 'call system using' to do a 'wc -l' to count the lines and create
the header record, then a 'cat >>' to append the temp file.  The 'wc -l' is
the only way to absolutely guarantee your count represents the number of
records that got written (as opposed to the number of records you asked your
program to write).



Wayne Ivory
Information Services
Iluka Resources Limited

-----Original Message-----
From: Bruce Weinstein [mailto:bruceweinstein@CANADA.COM]
Sent: Wednesday, 25 August 1999 03:03
To: Multiple recipients of list SQR-USERS
Subject: Modify record in flat file


I have a SQR that writes to a flat file.  Problem is the first record in the
file is supposed to be a header record containing general info.  One item it
is to contain is the number of records in the flat file.  I do not know this
value until the very end of running this SQR.  What I need to be able to do
is create my flat file with the header record as row 1, then when the SQR
has finished writing to the file, go back and update  the header record with
the number of records in the file.  My question is can I go back and update
the header row (Row 1) after writing all the records to the file first?

Your help would be appreciated.

Bruce Weinstein
E-mail: bruceweinstein@canada.com