Michael Pavling wrote:> On 23 August 2010 08:28, Sudheendra Panganamala
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
> wrote:
>> Hi,
>>
>> Is there any way to iterate through MySQL Result Hash multiple times ?
>>
>> Current Problem: After One iteration, second iteration no records.
>
>
> If you post the code you''re having a problem with, then maybe we
can
> make some suggestions.
>
> Ideally, the smallest sample of the code that exhibits the problem
> you''re experiencing so the model query and the loop should
suffice.
Here goes the code
journal_details = conn.dbconnection.query(
"SELECT value,prop_key from Journal_Details
INNER JOIN journals on journals.id = journal_details.id
WHERE journalized_id = ''#{issue_id}'' and
Date(created_on)=''#{date}'' ORDER By journals.id"
)
#The above is the query which results few records
journal_details.each_hash do |journal_details_record|
# Do some processing
end
journal_details.each_hash do |journal_details_record|
# I need to do reuse the query here so that i can do some other
processing.
# But this loop will not come inside
# I am thinking if there is any EOF kind of thing has been reached.
# And i do not know how to reset the pointer to point first record
end
Also I have tried with each method instead of each_hash. Same problem
continues.
Thank in advance for your help
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.