dynamic-update

On Fri, Jan 9, 2009 at 2:34 AM, Scott <[email protected]> wrote:

>
> I have a database table that has a number of fields, one of which is
> called ViewCount and is numeric. I want to increment this value for a
> record anytime its information is displayed, but am not sure how best
> to do this with ActiveRecord.
>
> If I were not using ActiveRecord, I'd create a stored procedure that
> did something like:
>
>   UPDATE TableName SET ViewCount = ViewCount + 1 WHERE ID = X
>
> And I'd call that stored procedure from my middle tier whenever the
> method that retrieves a record for display is called.
>
> I know that with ActiveRecord I could add something like the following
> to my middle tier:
>
>    MyObject obj = MyObject.Find(id);
>    obj.ViewCount++;
>    obj.Update();
>
> And that would do the trick, but my concern is that the database table
> includes a number of columns that contain large amounts of text and
> binary data. I am worried about performance if every time I increment
> ViewCount I am pulling back the values in these potentially large
> columns. Is there a way to tell ActiveRecord to not pull back ALL
> columns when I do a Find, or is there some other approach I should be
> taking to increment a counter field?
>
> Thanks!
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to