basi wrote:
Hello,
I'm trying to do record upates as follows:
tgl_analysis.select.each do |t|
if t.exception != 'y' then
tgl_analysis.update {|r| r.recno == t.recno}.set do |r|
r.word = (some value)
r.prefix = (some value)
end
end
end
This code removes the selected records, replacing them with blank
lines.
What did I miss?
When KirbyBase updates a record it tries to write the updated record back to the same spot in the physical file where it was before the update. However, if the updated record is now longer than the original record, KirbyBase blanks out the line in the file where the original record was and appends the updated record at the bottom of the physical file.
It does this because it is much faster to do this than to have to rewrite every record below the spot where the updated record is going to go. It is much faster and easier to just blank out the line where the record was, and then write the updated record at the end of the file where there is enough room to accomodate the increased record length. This is all transparent to the user. KirbyBase handles updating all of the indexes and such. The only time you would notice it is if you opened up the table's physical file in a text editor.
So, that is what I think is happening here. If you are saying that the lines are blank, I am assuming you are opening up the physical file and looking at it. The updated records should now be at the bottom of the file. If you do another #select on those records, they should be updated.
Once you start getting a lot of blank lines, you can run #pack to get rid of them.
Let me know if this answers your question.
Jamey Cribbs
Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.