Update multiple records

2 views
Skip to first unread message

stephend

unread,
Jun 2, 2009, 6:49:29 PM6/2/09
to transfer-dev
Hi,

Been using for transfer for awhile now but this is the first time I
have had to update a group of records in a table.
This is easy in straight SQL but how do you do it with transfer.

eg. Update tableName set defaultRec = "Y" where user = "xxxxx"

Thanks.

Bob Silverberg

unread,
Jun 2, 2009, 8:27:41 PM6/2/09
to transf...@googlegroups.com
You cannot do that with Transfer, not in the way you suggest anyway.  Transfer works with objects, not table rows, so you'd have to ask Transfer to get each object, update its property and then ask Transfer to save the object.  You could use one of the listXXX methods to get a query that contains the records you are interested in, and then loop over that query, getting each object, etc. 

If the expected number of records is small this will probably be fine, but if it may be a large number then you'd probably be better off just coding it in SQL.  If you do go that route (using SQL) don't forget to discard the objects from the cache after you update them - otherwise your cache will be out of synch.

Cheers,
Bob
--
Bob Silverberg
www.silverwareconsulting.com

stephend

unread,
Jun 2, 2009, 8:41:46 PM6/2/09
to transfer-dev
Hi Bob,

Thanks for the reply, as it is a small list of records I have taken
the route you suggested using listByQuery() and it works fine.

Cheers
Stephen

On Jun 3, 10:27 am, Bob Silverberg <bob.silverb...@gmail.com> wrote:
> You cannot do that with Transfer, not in the way you suggest anyway.
> Transfer works with objects, not table rows, so you'd have to ask Transfer
> to get each object, update its property and then ask Transfer to save the
> object.  You could use one of the listXXX methods to get a query that
> contains the records you are interested in, and then loop over that query,
> getting each object, etc.
>
> If the expected number of records is small this will probably be fine, but
> if it may be a large number then you'd probably be better off just coding it
> in SQL.  If you do go that route (using SQL) don't forget to discard the
> objects from the cache after you update them - otherwise your cache will be
> out of synch.
>
> Cheers,
> Bob
>
Reply all
Reply to author
Forward
0 new messages