I was trying to write the whole record with updates before and failed.  The
problem is in the update data.  If the sizes of old and new data are the same,
no problem.  If old data size is bigger, it erases data from the following
field.

Attached is some code in my application to handle the update.  I checked the
content of rec after line3 and it was unpacking correctly with rec.Data[attrPos]
= "Y" and rec.Data[attrPos + 1] = "Y".  Then I assign value in newChoice ("NA")
to rec.Data[attrPos] and tried to save it.  I checked again after line7 and
found that data in rec.Data[attrPos] = "".  Both my Pack and Unpack functions
don't change values in rec.  Thanks.


MemHandle           h;
FrpAdmin       rec;
FrpAdminPacked*     packed;
char*               newChoice;
UInt16              attrPos;

h = DBRetrieveByFrpId(gFrpIdSelected, FRPADMIN, &recordIndex);         //line1
packed = (FrpAdminPacked*) MemHandleLock(h);                 //line2
UnpackFrpAdmin(&rec, packed);                           //line3
rec.Data[attrPos] = newChoice;                                    //line4
MemHandleUnlock(h);                                     //line5
h = DBRetrieveByFrpId(gFrpIdSelected, FRPADMIN, &recordIndex);         //line6
PackFrpAdmin(&rec, h);                                       //line7




|--------+----------------------->
|        |          hartman@oneto|
|        |          uch.com      |
|        |                       |
|        |          10/02/00     |
|        |          05:39 PM     |
|        |          Please       |
|        |          respond to   |
|        |          palm-dev-foru|
|        |          m            |
|        |                       |
|--------+----------------------->
  >-----------------------------------------------------------|
  |                                                           |
  |       To:     [EMAIL PROTECTED]              |
  |       cc:                                                 |
  |       Subject:     Re: How to update a specified field in |
  |       the database                                        |
  >-----------------------------------------------------------|







[EMAIL PROTECTED] wrote in message <26052@palm-dev-forum>...
>
>
>
>I can't use offsetof() in my application.  My StructType is defined as
>typedef struct {
>UInt32  Id1;
>UInt32 Id2;
>char     Data[1];
>} StructType;
>
>I can use offsetof(StructType, Id1) to write to the first field, but how
can I
>update data in the 5th field (also have to consider there is also data in
the
>sixth field and new data might have a different size)?
>

You can't.  In a situation such as you describe it's better just to
read & write the whole record w/ paired pack() and unpack()
routines.

--
-Richard M. Hartman
[EMAIL PROTECTED]

186,000 mi/sec: not just a good idea, it's the LAW!




--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/tech/support/forums/




-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to