[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

KirbyBase 2.5: Problem pdating records

basi

12/13/2005 9:05:00 AM

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

3 Answers

Jamey Cribbs

12/13/2005 2:17:00 PM

0

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.


basi

12/13/2005 5:21:00 PM

0

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

Jamey Cribbs

12/13/2005 5:52:00 PM

0

basi wrote:

>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?
>
>
Well, probably the biggest news is that Assaph Mehr, 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 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.