Problem with space [message #139353] |
Tue, 27 September 2005 10:52 |
rajus19
Messages: 18 Registered: September 2005
|
Junior Member |
|
|
Hi All,
I have a flat file contains some records, I have to add a header and trailer to that flat file and store that in a new file.
I am not aware of how to put the space using unix commands, like in RPAD('BILLS',10,' ') in Sql query.
The problem is that in header I have to use that date picked from the database and some other things.Here is the example what it should be in a query, but I don't know what unix command to use to do the same thing.
ex: select '00'|| to_char(sysdate,'YYYYMMDD')||RPAD('STORE',10,' ')||RPAD('BILLS',10,' ')||'004'
||RPAD(' ',59,' ') from dual;
And in the trailer I have to use the count of the records in the original file. Here is the example if the count is picked from a table, but I have to pick the count from flat file and use a unix command to put the trailer.
ex: select LPAD(count(*)+2,8,0)||'91'||LPAD(count(*),8,0)||LPAD(sum(TRN_AMOUNT),11,0)||LPAD(' ',56,' ')
from MyTable;
Could you please help me,
you will be greatly apprecialted.
Thanks
Raju
[Updated on: Tue, 27 September 2005 10:55] Report message to a moderator
|
|
|
|
Re: Problem with space [message #139464 is a reply to message #139353] |
Wed, 28 September 2005 02:46 |
rajus19
Messages: 18 Registered: September 2005
|
Junior Member |
|
|
Thanks for the help.
For header its ok, but for trailer I need to use the count of records in the flat file.
If my source is the table I can use the query, but the source is a flat file, I am not sure what command to use for the trailer.
Thanks in Advance
Raju
|
|
|
|
Re: Problem with space [message #139645 is a reply to message #139524] |
Thu, 29 September 2005 01:09 |
rajus19
Messages: 18 Registered: September 2005
|
Junior Member |
|
|
hey sory for not explaining my problem properly.
The problem is I need help in writing trailer record.
ex: record_count=`cat $1 | wc -l ` (say 14 )
and if total_amount is 1500.
I have to write the trailer format as
Field---------Length---Format--Description
Account Type----2-------Constant:15
Record count----8--------N-------Count of all records in file.
Totol Amount-----11-------N------Sum total of all transactions
Filler----------------71-----------AN----------Spaces
Now I need a unix command to wirte the trailer record.
Thanks
Raju
[Updated on: Thu, 29 September 2005 01:57] Report message to a moderator
|
|
|