dbTalk Databases Forums  

SetGenFiltered TCursor and movetoRecord

comp.databases.paradox comp.databases.paradox


Discuss SetGenFiltered TCursor and movetoRecord in the comp.databases.paradox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Craig
 
Posts: n/a

Default 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
error..
This is part of a Scan Loop with a different TCursor (P10)

Thanks in advance.
Craig

<snip>
dyn["HospitalNumber"] = stNewMR
tcBounce1.setGenFilter(dyn)
licount = TCBounce1.nrecords()

If licount <2 then;// if less than 2 records nothing to compare..move
on to next patient
Loop
ENDIF

For lio from 1 to liCount-1
TCBounce1.movetoRecord(lio)
dtDCDatetime = TCBounce1."DCdateTime"
If not TCBounce1.movetoRecord(lio+1) then ;// <---this does not
happen!!!!
errorshow("Could not move to record "+STrval(lio +1));// <-- the
errorshow show doesn't show
return
Else
dtAdmitDateTime = TCBounce1."AdmitDateTime"
ENDIF
<snip>



Reply With Quote
  #2  
Old   
Liz McGuire
 
Posts: n/a

Default 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.

Liz


Craig wrote:
Quote:
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
error..
This is part of a Scan Loop with a different TCursor (P10)

Thanks in advance.
Craig

snip
dyn["HospitalNumber"] = stNewMR
tcBounce1.setGenFilter(dyn)
licount = TCBounce1.nrecords()

If licount <2 then;// if less than 2 records nothing to compare..move
on to next patient
Loop
ENDIF

For lio from 1 to liCount-1
TCBounce1.movetoRecord(lio)
dtDCDatetime = TCBounce1."DCdateTime"
If not TCBounce1.movetoRecord(lio+1) then ;// <---this does not
happen!!!!
errorshow("Could not move to record "+STrval(lio +1));// <-- the
errorshow show doesn't show
return
Else
dtAdmitDateTime = TCBounce1."AdmitDateTime"
ENDIF
snip



Reply With Quote
  #3  
Old   
Anders Jonsson
 
Posts: n/a

Default Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 06:37 AM



Quote:
*assumes nRecords() works right on a filter, I'm not sure.
From the help files:

"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. "

Anders





Reply With Quote
  #4  
Old   
Egbert Babst
 
Posts: n/a

Default Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 10:39 AM



Craig,
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
etc...
endScan

Egbert



Reply With Quote
  #5  
Old   
Egbert Babst
 
Posts: n/a

Default Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 10:40 AM



Oops
missing the ":"
scan TCBounce1 for TCBounce1."HospitalNumber"=stNewMR:

Egbert

"Egbert Babst" <EgbertBabst (AT) BabstSoft (DOT) com> schrieb im Newsbeitrag
news:45d88145$1 (AT) pnews (DOT) thedbcommunity.com...
Quote:
Craig,
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
etc...
endScan

Egbert




Reply With Quote
  #6  
Old   
Liz McGuire
 
Posts: n/a

Default 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.

FWIW,

Liz


Egbert Babst wrote:
Quote:
Craig,
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
etc...
endScan

Egbert



Reply With Quote
  #7  
Old   
Egbert Babst
 
Posts: n/a

Default Re: SetGenFiltered TCursor and movetoRecord - 02-18-2007 , 04:37 PM



Liz,
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...
;-))

Egbert

"Liz McGuire" <liz (AT) paradoxcommunity (DOT) com> schrieb im Newsbeitrag
news:45d89914 (AT) pnews (DOT) thedbcommunity.com...
Quote:
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.

FWIW,

Liz



Reply With Quote
  #8  
Old   
Craig
 
Posts: n/a

Default 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.
Craig



Reply With Quote
  #9  
Old   
Craig
 
Posts: n/a

Default 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.....
Thanks, Craig

"Craig" <craig.futterman (AT) nospam (DOT) comcast.net> wrote

Quote:
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.
Craig



Reply With Quote
  #10  
Old   
Anders Jonsson
 
Posts: n/a

Default Re: SetGenFiltered TCursor and movetoRecord - 02-19-2007 , 04:27 AM



Craig,

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
right direction.

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.

Anders





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.