My db is sorted based on the 1st int (fid) and then on
the 2nd int (sid). Not sure if the problem is with the
comparing function, I don't think the find function is
doing what it supposed to do.
typedef struct{
Int32 fid;
Int32 sid;
Char fields;
}DBPacked;
typedef struct{
Int32 fid;
Int32 sid;
Char *f1;
Char *s1;
Char *f2;
Char *s2;
}DBRecord;
/* the compare function */
Int16 CompareIDFunc(DBPacked *p1, DBPacked *p2, Int16
i, SortRecordInfoPtr s1, SortRecordInfoPtr s2,
MemHandle appInfoH){
Int16 result;
if ((p1->fid - p2->fid) < 0)
result = -1;
else if (p1->fid - p2->fid > 0)
result = 1;
else {
if ((p1->sid - p2->sid) < 0)
result = -1;
else if ((p1->sid - p2->sid) > 0)
result = 1;
else
result = 0;
}
return result;
}
/* the call to sort - this should work, right */
DmInsertionSort(db, (DmComparF *) CompareIDFunc, 0);
/* the call to find */
DBPacked findRecord;
findRecord.fid = gfID;
findRecord.sid = gsID;
recnum = DmFindSortPosition(db, &findRecord, 0,
(DmComparF *) CompareIDFunc, 0);
...
...
So, if a record is found (there should be only one
record found, because fid and sid server as primary
key), I should be able to read the record with:
recHandle = DmQueryRecord(db, recnum - 1);
What if there isn't any match, what value the recnum
would be? I'm strictly reading from db, no write.
Thanks much.
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/