need_a_roll_back_mechanism [message #497265] |
Fri, 04 March 2011 12:48 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
m_shehpar
Messages: 73 Registered: October 2010 Location: Pakistan
|
Member |
|
|
hi all,
in a when timer expire trigger (after a when validate record) i have prompted the user to save the record otherwise his record will be
rollbacked...
--------------------------------------------------------------------------------
IF SHOW_ALERT ('SAVE_CHANGES') = ALERT_BUTTON1 THEN
COMMIT;
ELSE
rollback;
--------------------------------------------------------------------------------
"if" part works fine but when the else part is executed another built in PROMT/ MESSAGE is popped asking to choose YES/NO/CANCEL for the change to occur which is against my interest... plus the whole form is cleared after rollback... i want to do all this via my own alert buttons and dont want my entire form or the block to be cleared when the trigger fires for a particular record
can anyone help me to escape this situation???? or give me an equivalant logic...
regards
i use Forms [32 Bit] Version 10.1.2.0.2 (Production
|
|
|
|
Re: need_a_roll_back_mechanism [message #497449 is a reply to message #497281] |
Sat, 05 March 2011 11:38 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
m_shehpar
Messages: 73 Registered: October 2010 Location: Pakistan
|
Member |
|
|
hi little foot,
i want to save the record after each record validation cuz i have formulated a mechanism to keep my auto advancing number (componint_no) automatically advancing...
in validate record i have written like:
IF :SYSTEM.RECORD_STATUS <> 'QUERY' THEN
SELECT MAX(componint_no)+1 INTO :blood_bank.componint_no FROM STORE
WHERE branch_id = 'HBFP';
:BLOOD_BANK.BRANCH_ID := 'HBFP';
vTimer := create_timer ('SAVE_REC', 100, NO_REPEAT);
END IF;
in when timer expire i have written:
IF vcTimer = 'SAVE_REC' THEN
IF SHOW_ALERT ('STORE_INS_SAVE') = ALERT_BUTTON1 THEN
COMMIT;
ELSE
ROLLBACK;
--PREVIOUS_RECORD;
--DELETE_RECORD;
END IF;
----------------------------------------------------------------
--PREVIOUS_RECORD;
--DELETE_RECORD;
this logic deletes the record even when an update is inteded to be rolled back, thus a saved record is lost...
whereas rollback statement does the desired job but it issues its own prompt too, (in addition to my own alert, as you could see in the when timer expire...) asking YES / NO / CANCEL and then clears the whole form...
can you people rectify this logic for me???. i dont want to use sequence for a number of relevant personel issues, so please
give me some other logic, if you have on your mind...
waiting eagerly
regards....
|
|
|
Re: need_a_roll_back_mechanism [message #497550 is a reply to message #497449] |
Sun, 06 March 2011 02:09 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
"MAX + 1" is a wrong mechanism in multi-user environment, because (sooner or later) two users will fetch the same "MAX + 1" (because, the first user won't commit yet, so the second one will get the same value. Then, when both of them commit, one will get the "duplication" error message). If the whole logic you developed is about gapeless sequence numbers, perhaps you'd want to read this discussion.
As of Quote:this logic deletes the record even when an update is inteded to be rolled back, thus a saved record is lost...
I think that you got it wrong. All changes you store into the database (using the COMMIT statement) can not be rolled back. True, form will be cleared, but - if you execute query - you'll fetch those records.
|
|
|
|
Re: need_a_roll_back_mechanism [message #497802 is a reply to message #497795] |
Mon, 07 March 2011 04:44 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Before applying ISSUE_ROLLBACK, Shehpar should read Help. It says that ISSUE_ROLLBACK is meant to be used in applications that run against a non-Oracle data source (which is not the case). It also says that results are unpredictable when it is used outside an ON-ROLLBACK trigger (which is the case here).
So ... I'm not sure it'll help much.
Also, perhaps it wouldn't hurt to read this Experts exchange discussion (scroll down, to the bottom of the page) (pay attention to the first schwertner's message).
|
|
|