[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: reading from a flat file
- Subject: Re: reading from a flat file
- From: "Sarabudla, Raji R." <Raji.R.Sarabudla@KP.ORG>
- Date: Tue, 6 Jul 1999 16:26:56 -0400
Hi Dhananjay,
You can achieve this by reading the flat file into variables and check
the Rec Type, if the Rec Type is A insert into
BI_HDR table, else insert into BI_LINE Table.
Make sure the Field Lengths,Date Formats etc. Read all the Values into
String Variables and Convert them into Numbers later. The following example
makes you easy to understand.
Example:
begin-procedure main
let $filename = 'C:\temp\temp.dat'
open $filename as 1 for-reading record=100 status=#filestat
while 1
read 1 into $RectYPE:2 $TransID:10 $Date:10 $CustID:10 $Cust#:10
$counts:4 $totalamt:12
! convert necessary string variables into number variables before
inserting.
let $RecType = rtrim($RecType,'')
let #counts = edit($counts,'99')
let #totalamt = edit($totalamt,'9999999.99')
etc.
if $RecType = 'A' --- When even the Rectype A reads, it inserts into
Header Table, otherwise, inserts into detail table.
insert into BI_HDR(RecType,TransID,TDATe etc.) Values
($RecType,$TransID,#counts,#totalamt etc.)
! make sure the syntax here.
else
insert into BI_LINE(RecType,TransID,TDATe etc.) Values
($RecType,$TransID,#counts,#totalamt etc.)
end-if
if #end-file
break
end-if
end-while
end-procedure
Hope this helps,
Raji
----------
From: Dhananjay Nikkam [SMTP:nikkam@hotmail.com]
Sent: Tuesday, July 06, 1999 3:35 PM
To: Multiple recipients of list SQR-USERS
Subject: reading from a flat file
Hi guys,
I am trying to read from a flat file, which consists of data for the BI_HDR
and the BI_LINE tables. That is Header and detail info. So one line of HDR
can consist of one or more detail lines. They are linked by a transaction
ID. The flat file looks like something below. Can anyone suggest the most
efficient way of acheiving this?
Rec TransID. Date CustID Cust# counts totalamt
type
--- ------- ---- ------ ----- ------ --------
A 11788 06/11/99 678 1 AXDDFF 7675
B 11788 50 4000)
B 11788 100 3675) line info
Rec. type A,is the header info and Rec type B, will be the line
info and linked by the TransID.
Thanks
DJ
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com