Dynamic updateable browse - CURRENT-ROW-MODIFIED

Serge

New Member
Hi,

Following is troubling me in a multi-user environment...

Ive got an input paramater as string that refers to a table name. For this table I want to create a temp-table which I want to use to create a dynamic updateable browse. When the user modifies a record, this record must be copied from the temp-table to the original table.

Also the system must check whether the record has already been modified by another user after initializing the dynamic browse. If so, the user must get a message to confirm if he still wants to update this record.

I had the following code but it is not doing what I want: Error = "record has NO-LOCK status, update field not allowed. I cannot use the Exclusive-Lock option in the query-prepare method. How can this be done?

Would appreciate any help.

def var hTable as handle no-undo.
def var hQuery as handle no-undo.
def var lChanged as logical no-undo init no.
def var i as int no-undo.


/* If user leaves row which has been modified */
IF hBrowse:CURRENT-ROW-MODIFIED THEN
DO:
/* load the modified row into record buffer and lock this record */
create buffer hTable for table ipTable:name.
create query hQuery.
hQuery:set-buffers(hTable).
hQuery:query-prepare("for each " + ipTable:name + " where userid = '" + hBrowse:get-browse-column(2):buffer-field:buffer-value + "' exclusive-lock").
hQuery:query-open().
hQuery:get-first().

/* Check if record has been modified already by an other user since loading the data in the dynamic browse */
repeat iColumn = 1 to hTable:num-fields:
hColumn = hBrowse:get-browse-column(iColumn).
hField = hColumn:buffer-field.
if hField:extent eq 0 then
if hField:buffer-value <> hTable:buffer-field(iColumn):buffer-value then
do:
assign lChanged = yes.
leave.
end.
else
do i = 1 to hField:extent:
if hField:buffer-value <> hTable:buffer-field(iColumn):buffer-value then
do:
assign lChanged = yes.
leave.
end.
end.
end.

/* If record alread has been modified by another user */
if lChanged then
do:
message "Record has already been modified by another user since the data has been loaded into the dynamic browse!" view-as alert-box warning.
end.
else
do:
repeat iColumn = 1 to hTable:num-fields:
hColumn = hBrowse:get-browse-column(iColumn).
hField = hColumn:buffer-field.
if hColumn:modified then
do:
do transaction:
assign hTable:buffer-field(iColumn):buffer-value = hBrowse:get-browse-column(iColumn):screen-value.
end.
end.
end.
end.

end.
 

Serge

New Member
Nobody any idea how to save changes in a dynamic updateable browse based on a temp-table or buffer? :confused:
 

Serge

New Member
OK, I'm feeling really stupid now :-$

I learn every day from this forum ...

Cheers Osborne.
 

Casper

ProgressTalk.com Moderator
Staff member
If you would use a dataset then the checking for changes is done with the save-row-changes mehtod. This way you wouldn't have to code for it.

Another way of checking changes is using the buffer-compare method. That way you wouldn't have to iterate through each field.

Casper.
 
Top