I'm having an indice out of range error while generating output from a
persistent rowset. It's basically the most used query in our database, on
our most viewed webpage. Caching the results definitely makes sense, here.
It acts like the rowset times out and clears itself while I'm iterating
through it. Is that even possible?
Here is my display code, where I get the indice out of range error:
<%
$hostname := html.jobs_host_prefix
// Do not escape the Notes field below, because it can have
if($qryAds->rowCount = 0)
%><h3>There are currently no opportunities available.</h3><%
else
$alt := true
$qryAds->beforeFirst
while ($qryAds->next)
$row := $qryAds->getRow
$alt := not($alt)
$rowClass := choose($alt; "alt"; "")
$no_training := choose(($row{"jid"}=0);'<span
class="text-info">*</span> ';"")
%>
<tr id="job<%=$row{"tid"}%>" class="<%=$rowClass%>">
<td><%=cell(mac to html($row{"company"};*))%></td>
<td><%=$row{"city"}+", AL"%></td>
<td><%=cell(job.job_link($row;"title";$hostname))%></td>
<td><%=cell($row{"endsAt"})%></td>
<td><%=$no_training%></td>
</tr>
<%
end while
end if
%>
Here is my code that builds the persistent rowset:
$rowsetName := persistent_rs.name("";"Ad";"active")
$qryAds := Rowset.persistent($rowsetName)
if ($qryAds # 0)
if (not($qryAds->timedOut))
return
end if
end if
$semaphore:="$queryAds"
if(not(semaphore($semaphore;200)))
$now := timestamp
query([ad];[Ad]status = "active"; *)
query([ad]; & ;[ad]StartsAt <= $now; *)
query([ad]; & ;[ad]EndsAt >= $now)
order by([ad];[ad]company; > ; *)
order by([ad];[ad]StartsAt; < ; *)
order by([ad];[ad]id; <)
$map := """
tid: [ad]id;
company: [ad]company;
endsAt: `ts.deadline([ad]endsAt)`;
title: [ad]JobTitle;
city: [ad]city;
jid: [ad]jobID;
"""
$qryAds := RowSet.newFromSelection(->[ad];$map;-1;"";$rowsetName;2) //
refreshes every two minutes
clear semaphore($semaphore)
end if
-----
If you can spot the problem, I'd appreciate the help. The error doesn't
present itself very often, but when it does, it's front and center -- and
embarrassing.
BTW, the ts.deadline routine simply decorates the contents of the ending
date and time with a color, to show urgency. There is no problem with this
method. Also, I'm using the semaphore to prevent the rowset from being
generated by two different requests. We were occasionally getting
duplicated segments of the rowset, otherwise.
Thanks,
Doug Hall
_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/