Come and join the fun with this tricky FORMS number !!!

hi,
imagine the following scenario.
user TOM is at site B and using a form to update a few records.
Meanwhile BOB at site A is doing the same on the same table. Suddenly BOB gets the "Could not reserve record" message. (They have encountered a lock)
Q. How can I programmatically inform BOB that TOM is the reason for the lock or vice versa ?
I need to get user from SQL AREA or something possibly?
Product is FORMS4.5 on win 95.
ANy ideas very welcome folks.
Please contribute.
thanks
nik.

At least until Oracle 8.1.7 there is no way to detected who is locking a record. But in Forms you can do
the following (in the next post I will discuss the benefits and limitations) :
- Create a table called user_locks with :
record_rowid rowid (primary key)
lock_id number(10)
user_locked varchar2(16)
datetime_locked date
- Define a database sequence called user_lock_id :
increment by 1
start with 1
minvalue 1
maxvalue 1073741823
cycle
- Create a procedure in the database to handle user locks :
create or replace procedure lock_user_record (
p_rowid in varchar2
) as
v_user_locked varchar2(8);
v_datetime_locked date;
v_lock_id pls_integer;
v_status pls_integer;
v_rowid rowid;
procedure insert_lock (
p_rowid in rowid,
p_lock_id in number
) is
pragma autonomous_transaction;
begin
begin
insert into user_locks
(record_rowid,lock_id,user_locked,datetime_locked) values
(p_rowid,p_lock_id,user,sysdate);
exception
when dup_val_on_index then
update
user_locks
set
lock_id = p_lock_id,
user_locked = user,
datetime_locked = sysdate
where
record_rowid = p_rowid;
end;
commit;
end;
begin
if p_rowid = 'AAAAAAAAAAAAAAAAAA' then
return;
end if;
v_rowid := chartorowid(p_rowid);
begin
select
lock_id,
user_locked,
datetime_locked
into
v_lock_id,
v_user_locked,
v_datetime_locked
from
user_locks
where
record_rowid = v_rowid;
exception
when no_data_found then
select
user_lock_id.nextval
into
v_lock_id
from
dual;
end;
v_status := dbms_lock.request(v_lock_id,6,0,true);
if v_status = 0 then -- Success
insert_lock(v_rowid,v_lock_id);
end if;
if v_status = 1 then -- Record locked by another user
raise_application_error(-20001,'Record locked by '||v_user_locked||' since '||to_char(v_datetime_locked)||' '||to_char(v_datetime_locked,'HH24:MI:SS')||'.');
end if;
if v_status = 2 then -- Deadlock detected
raise_application_error(-20002,'Deadlock detected.');
end if;
if v_status = 3 then
raise_application_error(-20003,'Parameter error trying to lock record.');
end if;
if v_status = 5 then
raise_application_error(-20004,'Illegal handle to lock record.');
end if;
end;
- On Forms redefine the trigger "ON-LOCK" :
lock_user_record(:block.rowid);

Similar Messages

Maybe you are looking for

  • Deploy mss 1.41

    Hi All, We have a requirement to install the Business Package for MSS and ESS 1.41. Our current level of Business package for MSS and ESS is 1.0. Is it mandatory to patch the following? SAP ESS 603 SAP PCUI_GP 603 Also, please let me know if any othe

  • Change notification E_mail text doesn't work in Portal 7.0

    I am changing notification E_Mail text accroding this link: <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/33/d494c86203ea40b7b44ddd471baab1/frameset.htm">http://help.sap.com/saphelp_nw04s/helpdata/en/33/d494c86203ea40b7b44ddd471baab1/framese

  • Emails disappear when placed in categories

    I moved several emails to one of my categories. They were there 2 days ago, but when I wanted to access now they went missing. Yes, I am sure I didn't accidentally delete. Not the oly category gone missing.

  • More than 1 records in one cell

    Hi all, I once came across someone's apex site whereby they've a form and one column contains more than one record. for e.g. customer1 ordered prducts abc, xyz, def, etc customer2 ordered one product xyz The form: Name  |Address |Product       |     

  • User interface lags severely on my 2.2GHz mbook pro 3,1

    I usually run my laptop just plugged in without battery ever since i had my first battery totally fry on me within 6 months of usage. And i needed to use my computer intensively the last few days so i plugged the battery in reset the computer reset p