Commit on Appserver

emnu

Member
Hi,

I have a problem while commiting database recs on an appserver procedure.

I have 2 procs, 1 local which holds the updated row when the user presses the saverec button.

This record is sent to the appserver procedure as table-handle.
On the appserver there is also a buffer for the table to commit the changes. ON appserver, a buffer handle to the update temp-table is created, and a buffer copy is executed to the table (after record is positioned to the right rec. pointer. The Update buffer has 2 exta fields, namely RowIdent which holds the rowid to search te record to commit and rowmod, which indicates if record is update or add.

SnapShot of Code:

/* If not bChanged, update record on serverside */

/* bhRowObjUpd_AI contains the changed record */
/* bhTable contains the current value before update */

IF NOT bChanged AND bhRowObjUpd_AI:AVAILABLE THEN DO:
rRowIdent = bhTable:ROWID.
bhTable:FIND-BY-ROWID(rRowIdent,EXCLUSIVE-LOCK).
bhTable:BUFFER-COPY(bhRowObjUpd_AI,"RowIdent,RowMod":U) NO-ERROR.
IF ERROR-STATUS:ERROR THEN
DO:
DO i = 1 TO ERROR-STATUS:NUM-MESSAGES:
ERROR-STATUS:GET-NUMBER(i).
cRet = cRet + " <15> " + ERROR-STATUS:GET-MESSAGE(i) + " ":U + CHR(13) + CHR(10).
END.
END.


Problem is that after the update occurs (buffer-copy) the record isn't changed at all, just reset to it's original values.

Ex. cusomter x changed to y,
after buffer-copy still x in database table.

Any clue ?

Thanx for any response,

Emmanuel.


bhTable:FIND-BY-ROWID(rRowIdent,NO-LOCK).

END.
 
Are you sure the change isn't getting to the DB?

I remember a having an issue a couple of years back where the value in the DB had been updated, but because a persistent procedure still had an old copy of the record in a buffer it any lookups wouldn't load the new record from the DB.

A quick fix for this issue is to read the record exclusive-lock which forces a refresh of the buffer from the db (Yuck, but a good starting point to see if this is your problem).

As a rule of thumb I always strong scope any db finds with local buffers in persistent procedures or AppServer routines.
 

emnu

Member
Hi All,


I was just looking with a colleage to the commit problem, when i had some of "lightning" in my head ! I found it once, you have to wrap a transaction around the buffer-copy while using dynamic objects !


Any way, thanx for the responses,


Emmanuel
 
Top