Multi-user updates using the OWS without Locking Tables
SELECT and an UPDATE initiated from a Web Browser occur at different
times on the Web because HTTP doesn't maintain state. A workaround is
to let the PL/SQL display the data for updating also store the data
values in hidden HTML fields. For Example:
for x in (select rowid, a.* from emp a) loop
htp.FormHidden('the_rowid', x.rowid);
htp.Print('Enter new Employee Name:');
htp.FormHidden('old_ename',x.ename);
htp.FormText('new_ename', x.ename);
end loop;
The values in the form with can now be compared to the current table
values before allowing the update occur. For Example:
UPDATE emp SET ename = new_ename
WHERE rowid = the_rowid
AND ename = old_ename;
if (SQL%ROWCOUNT = 0) then
htp.print('Row has Changed, please re-query before updating.');
else
htp.print('Row updated.');
end if;
If the Update occurs it is done to the data because it matched data from
the select. If the current data doesn't match, the user is told to
re-query the data. This will work in a low transactional system, but
may be annoying to users in a high transaction systems.