# KirbyBase 2.5: Problem pdating records

**URL:** <https://www.ruby-forum.com/t/kirbybase-2-5-problem-pdating-records/50125>\
**Category:** Ruby\
**Created:** [December 13, 2005, 10:09am UTC](https://www.ruby-forum.com/t/kirbybase-2-5-problem-pdating-records/50125 "2005-12-13T10:09:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![basi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a3d4f5/32.png) [@basi](https://www.ruby-forum.com/u/basi)\
**Post date:** [December 13, 2005, 10:09am UTC](https://www.ruby-forum.com/t/kirbybase-2-5-problem-pdating-records/50125/1 "2005-12-13T10:09:41Z")

</div>

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?

Thanks!  
basi

---

<div class="post-metadata">

**Author:** ![basi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a3d4f5/32.png) [@basi](https://www.ruby-forum.com/u/basi)\
**Post date:** [December 13, 2005, 6:54pm UTC](https://www.ruby-forum.com/t/kirbybase-2-5-problem-pdating-records/50125/2 "2005-12-13T18:54:27Z")

</div>

basi wrote:

> 

Well, probably the biggest news is that Assaph M., the author of  
Pimki, is working on an ActiveRecord adapter for KirbyBase, called  
Ackbar. I think he has the CRUD functionality working and is now  
implementing the associations (i.e. has\_many, belongs\_to).

Other than that, I have a few bug-fixes that I have made, but no new  
features. If anyone has anything they would like to see, please email  
me or go to KirbyBase’s RubyForge page and add your request.

I am in the process of, very slowly, bringing the Python version of  
KirbyBase up to date with the Ruby version. So, if any of you program  
in both languages, this might interest you.

Jamey C.

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.

---

<div class="post-metadata">

**Author:** ![basi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a3d4f5/32.png) [@basi](https://www.ruby-forum.com/u/basi)\
**Post date:** [December 13, 2005, 3:19pm UTC](https://www.ruby-forum.com/t/kirbybase-2-5-problem-pdating-records/50125/3 "2005-12-13T15:19:51Z")

</div>

basi wrote:

> 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 C.

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.

---

<div class="post-metadata">

**Author:** ![basi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a3d4f5/32.png) [@basi](https://www.ruby-forum.com/u/basi)\
**Post date:** [December 13, 2005, 6:24pm UTC](https://www.ruby-forum.com/t/kirbybase-2-5-problem-pdating-records/50125/4 "2005-12-13T18:24:16Z")

</div>

It is, as you explained, exactly what is happening here. Yes, the  
updated records are appended back at the end of the table. (The table  
is large and I didn’t scroll far down enough to have seen the records;  
my apologies.)

All’s well and good. And thanks again for KirbyBase and the great  
support.

Anything that KirbyBasers would be interested to know that is coming  
down the pipes?

Thanks!  
basi
