SetGenFiltered TCursor and movetoRecord - 02-17-2007 , 07:22 PM
In the following code snippet, the TCursor dosen't move to the next record
which is record lio+1
The code steps through the line with the errorshow, but it doesn't show the
This is part of a Scan Loop with a different TCursor (P10)
Thanks in advance.
dyn["HospitalNumber"] = stNewMR
licount = TCBounce1.nrecords()
If licount <2 then;// if less than 2 records nothing to compare..move
on to next patient
For lio from 1 to liCount-1
dtDCDatetime = TCBounce1."DCdateTime"
If not TCBounce1.movetoRecord(lio+1) then ;// <---this does not
errorshow("Could not move to record "+STrval(lio +1));// <-- the
errorshow show doesn't show
dtAdmitDateTime = TCBounce1."AdmitDateTime"
Re: SetGenFiltered TCursor and movetoRecord - 02-17-2007 , 07:44 PM
I'm not sure, but it's possible the record numbers aren't sequential
when you set a filter (unlike a range or unfiltered/unranged table).
Probably, you have to do a while true loop or just increment the count*
var and use nextRecord - either way, quit when you reach liCount-1.
*assumes nRecords() works right on a filter, I'm not sure.
If there were an index on HospitalNumber, so you could set a range, your
code would work by replacing the filter with a range.
Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 06:37 AM
"When you call nRecords after setting a filter, the returned value does not
represent the number of records in the filtered set. To get that
information, use cCount. "
Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 10:39 AM
why not using a scan-loop instead?
You could avoid the setGenFilter by using the for-clause of then scan like:
scan TCBounce1 for TCBounce1."HospitalNumber"=stNewMR
Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 10:40 AM
missing the ":"
scan TCBounce1 for TCBounce1."HospitalNumber"=stNewMR:
"Egbert Babst" <EgbertBabst (AT) BabstSoft (DOT) com> schrieb im Newsbeitrag
news:45d88145$1 (AT) pnews (DOT) thedbcommunity.com...
Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 12:21 PM
That would make it slightly harder to do what he wants as he needs to go
to record #1, read a value, then inside the loop, go to record #2 and
compare it to record #1, then repeat for every pair of records (or
something like that). This kind of thing is easier in a loop where you
control the record movement rather than the loop controlling it.
Given what Anders had to say, I'm guessing a secondary index and
setRange would simplify life greatly.
Egbert Babst wrote:
Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 04:37 PM
OK, I didn't recognize the need to compare values by bouncing forward or
back to succeeding records or so.
If so, no doubt, setRange would be best.
With or without scan depends...
I still admire Paradox for all the different ways to reach a goal.
May be you're right as he already is in a scan loop...
"Liz McGuire" <liz (AT) paradoxcommunity (DOT) com> schrieb im Newsbeitrag
news:45d89914 (AT) pnews (DOT) thedbcommunity.com...
Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 08:09 PM
Liz, Egbert and Anders,
Thanks, as always, for your replies.
After doing a query which combines two tables from a specified time frame, I
am going through each of the records, one by one, and looking for records
which have the same medical record number and comparing the discharge
datetime with the admission datetime of the next record. The goal is looking
for patients who come back to the ICU within a specified period of time (24
or 48 hours). The purpose is to investigate why kids "bounce back" in a
short period of time.
According to what you suggest, I will have to create an index on the
hospital number field after the query which creates the table. Then, as I go
through the table with a scan loop, set the range for the hospital number,
compare records and find the "bouncebacks". I have to reset the range each
time the big scan loop goes to the next patient.
Does that sound correct? Can I go through a scan loop of the entire table
and use set range after each record?
Thanks for helping me with this complex project.
Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 08:51 PM
As I have done more think about this, I have another question:
Should I have 2 Tcursors or a TCursor and a table variable, one which
increments step by step to get the next hospitalnumber and the other to
setrange and get the data?
Or should I have two copies of the table, one to go down step by step and
the other to do the set range?
My feeling is it should be the first, but I need expert opinions.....
"Craig" <craig.futterman (AT) nospam (DOT) comcast.net> wrote
Re: SetGenFiltered TCursor and movetoRecord - 02-19-2007 , 04:27 AM
Not entirely sure I follow what you want to do, but you certainly don't need
several copies of the table. Instead you can open several tCursor against
the same table but use different indexes and ranges.
If you have a secondary index that includes HospitalID, PatiendID and
DateOfVisit you could do something
1) Open a tcursor against the table.
2) Open another tCursor against the same table but with the secondary index.
3) Scan the first tCursor, for each record in that one do a setRange with
the secondary tcursor, using exact match for HospitalID, PatientID and a
range form DateOfVisit.
4) Check out the the records in the range and see how many returning visits
and add them to a temporary result table for a report.
Not sure my explanation is clear enough but I hope it will point you in the
I think it's essential that you create the correct secondary indexes as
setRange often is MUCH quicker than setGenFilter and queries and if you have
many records it will make a huge difference in performance.