• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

(B&S) Help with my Update()

 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I have tried and searched this forum on help with my update(). I seem not to understand some fundamentals and i will be grateful if someone could direct me to a post that will help my plight. I therefore post my sections of update method and ask for directions. If some sections of the posted code violates any code of conduct of the ranch, pls the moderator can feel free to edit sections of the code and i apologise:


Thank you as you help out.
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Saheed,

I dont see a question in your post - is there something you are asking about?

Regards, Andrew
 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Sorry i guess i forgot. When ever i do a Book() say for the 4th record, it distorts the remaining records(i.e i dont get to see records 5 - 29) and the updated 4th record isnt in arranged at all, the "Types of Work" column, "Number of staff" column "Hourly rate" and "Owner" column have their records distorted. What i guess happened is the length of data i am writing is more than the required one specified in the datafile. But i am sure i am taking care of that while writing. My question is: Is there is problem with the way i am writing my data to the data file?
 
Andrew Monkhouse
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow, so much code - more than I want to handle in one hit. So I will look at bits and pieces, not necessarily all at once.

What would happen if the 'if' statment wasnt there and you only had the 'else' action. That is, what would happen if you called "raf.seek(offset + ( recNo - 1) * (recordLength + VALID_RECORD_INDICATOR ) );" with a recNo of 1?

What is this gaining you? That is, what is the value in using newRecords[] in your remaining code instead of using data[]?

What happens if a field provided to you is longer than the allowed field length?

What is 'a' (used in "recordStringBuffer.append(a);")?

In the buffer you write to file, are you accounting for the valid record indicator?

Regards, Andrew
 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Andrew Monkhouse:
Wow, so much code - more than I want to handle in one hit. So I will look at bits and pieces, not necessarily all at once.

What would happen if the 'if' statment wasnt there and you only had the 'else' action. That is, what would happen if you called "raf.seek(offset + ( recNo - 1) * (recordLength + VALID_RECORD_INDICATOR ) );" with a recNo of 1?

What is this gaining you? That is, what is the value in using newRecords[] in your remaining code instead of using data[]?

What happens if a field provided to you is longer than the allowed field length?

What is 'a' (used in "recordStringBuffer.append(a);")?

In the buffer you write to file, are you accounting for the valid record indicator?

Regards, Andrew



Hi
Interesting points highlighted by you Andrew! I saw somethings that really were in-efficient. The 'a' value in my code was pointing to a null value, but i realised that i could simply append spaces instead of nulls cause when i checked the data file in TextPad i realised it was padded with spaces and there wasnt any null/funny characters, so i am assuming there is some kind of confusion in the requirement of the customer. Anyways that aside, my problem is with the actual writing to the file. I have taken care of when the incoming data is greater than the required length, my problem is when you say, i am catering for the Valid flag:
Here I give a scenario of what i "think" is happening when u want to write to the data file:

That is my thinking process(and it isnt working so far so i know there is a problem). Are you saying that I would have to account for the VALID-RECORD flag. Do i write it before i start actually writing the actual updates? Thank you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic