Home » Developer & Programmer » Forms » Locking Problem
Locking Problem [message #82616] Fri, 13 June 2003 01:32 Go to next message
Padmalaya Nanda
Messages: 7
Registered: June 2003
Junior Member
Hi,

I'll tell you what exactlt I'm doing currently.

My form is f1.fmb and block is b1, x is an item in block b1.

I've written a post-query trigger on block b1
b1.x := b1.x+10;

This causes on-lock trigger to fire

On-lock trigger is

begin
lock_record;
if not form_success
then
message('lock error');
raise form_trigger_failure;

exception
when others
then
raise form_trigger_failure;
end;

When i run this form for the first time, there's no error

When I run it for the second time from a different
instance , I get the alert first, then 'FRM-40501' error.

So pls. help to solve this problem,

I can't use your solution, because, there are more than 100 forms calling a central libraray
where on-lock trigger is written. I can't create a cursor there ,
coz it's never known waht is the select statement of the form and which
items of the form will be disabled.

So pls. help some other solution.
Re: Locking Problem [message #82618 is a reply to message #82616] Fri, 13 June 2003 02:54 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Well,
your setup is making it rather difficult for us to come up with a solution:
I just see this option left:

1. Change the ON-LOCK trigger in the library to use just the standard behaviour (i.e. LOCK_RECORD), without any exeption handling or other fancy stuff. That way you don't have to change all triggers in all forms and you re-establish standard forms behavior.

1. Create a Dynamic function fun$lock_record on the DB like this:
Function    FUN$LOCK_RECORD 
  ( p_table_name In VARCHAR2
  , p_rowid In ROWID
  )
  RETURN  NUMBER IS
  Type t_cur_type Is Ref Cursor;
  c_cur t_cur_type;
  lock_error Exception;
  Pragma Exception_Init(lock_error, -54);
BEGIN 
  Open c_cur For 'SELECT 1 FROM :tab WHERE ROWID = :rowid For Update Nowait' Using p_table_name, p_rowid;
  RETURN 0;
EXCEPTION
   WHEN lock_error THEN
     Return 1;
   When others then
     RETURN SQLCODE;
END; -- Function FUN$LOCK_RECORD
In the Program Unit Fun$Lock (this should be included in a library too) you change the code to:
Begin
  Return fun$lock_record(Get_Block_Property(:System.Cursor_Block, DML_DATA_TARGET_NAME),:EMP.ROWID);
End fun$lock;
Beware that this will only work for blocks which are based upon a database table (no views without ROWID), and note that the 'ROWID' pseudocolumn *normally* is automatically included.

It's a last shot, and you still have to include the POST-QUERY functionality, but only in the forms that pose a problem concerning the FRM-40501 message.

If this doesn't work out then I'm out of ideas.

MHE
Previous Topic: Major Difference between Property class and Visual attribute
Next Topic: Locking Problem
Goto Forum:
  


Current Time: Fri Apr 26 15:28:30 CDT 2024