CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Missing character in flat file database

 



datlaravi
Deleted

Jan 11, 2001, 4:36 AM

Post #1 of 1 (327 views)
Missing character in flat file database Can't Post

Hi,
I am trying to write the records to the flat file database. Everytime i submit the form, the following code will print a record to the database. For every record, the following $gtmid will get incremented.

$reclength = 185;
$gtmidlength = 10;
$pos = (($gtmid - 1) * $reclength) + $gtmidlength;

seek(RECORDDB, $pos,0);

print RECORDDB pack ("A30 A8 A25 A25 A8 A10 A15 A12 A8 A8 A8 A8 A A20",$contents{GTMSalesRep},
$contents{TodaysDate},$contents{EndUser},
$contents{EmployeeRegion},$contents{calcpoints},
$contents{EmployeeDistrict},$contents{AppDeal},
"PENDING EUDM","","","","","Y","$contents{EmployeeId}$gtmid.html");
If i submit 3 times,
Output of the Record is

Peter Marcot, 01/10/01, End User, Region, Calcpoints, District, Deal, PENDING EUDM, Y, 12801.html

Peter Marcot, 01/10/01, End User, Region, Calcpoints, District, Deal, PENDING EUDM, Y, 12801.html

Peter Marcot, 01/10/01, End User, Region, Calcpoints, District, Deal, PENDING EUDM, Y, 12801.html

Peter Marcot, 01/10/01, End User, Region, Calcpoints, District, Deal, PENDING EUDM, Y, 12801.html


What i was doing is, i was replacing the 1st record with another record. It is working fine. When i replace the 1st record with another record, I am loosing 1st character in the next record.
The following code replaces 1st record with replace information.
$reclength = 185;
$readbuf = "";
$readcount = 0;
$recoffset = (($contents{GtmID} - 1) * $reclength) +$gtmidlength;
seek(RECORDDB,$recoffset, 0);
$readcount = read(RECORDDB, $readbuf, $reclength);

($GTMSE,$TodaysDate, $EndUser,$Region, $Points,$District, $EstDealSize,
$CurrStatus, $EUDMDate, $DMDate, $RDDate, $FinDate, $IsRecView, $readPtr)
=unpack("A30 A8 A25 A25 A8 A10 A15 A12 A8 A8 A8 A8 A A20", $readbuf);

Output after Replacing is

John, 01/011/01, User, Local, 12, Comm, Market deal, PENDINGDM,12/01/01,12/01/01,12/01/01,12/01/01,Y,12801.html
eter Marcot, 01/10/01, End User, Region, Calcpoints, District, Deal, PENDING EUDM, Y, 12801.html
Peter Marcot, 01/10/01, End User, Region, Calcpoints, District, Deal, PENDING EUDM, Y, 12801.html

If you notice, the 2nd record is missing one character. Please help me I need this very badly. I tried counting all the characters. It comes to 186. When i tried using the $reclength 186, it is not even writing record to the database. Only if i use 185, the record is writing to the database and the problem with it is the 2nd record is missing the character.

Please help me.

Thanks in advance







 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives