Home » Developer & Programmer » Forms » Trigger on save button?? (forms 6i)
Trigger on save button?? [message #600114] Thu, 31 October 2013 20:37 Go to next message
sanjlaxmi
Messages: 24
Registered: October 2013
Junior Member
which is the trigger that fires when we Press the Standard 'Save' button from the toolbar?
and i want to update the record on another table which is not in data block by using this save button?
@ that time i want to display message like transaction complete:1 records saved..how to do this??

pls help me to find out solution..
thanx.
Re: Trigger on save button?? [message #600118 is a reply to message #600114] Fri, 01 November 2013 01:07 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This is the KEY-COMMIT trigger.
Re: Trigger on save button?? [message #600129 is a reply to message #600118] Fri, 01 November 2013 03:02 Go to previous messageGo to next message
sanjlaxmi
Messages: 24
Registered: October 2013
Junior Member
thanx...
Re: Trigger on save button?? [message #600133 is a reply to message #600129] Fri, 01 November 2013 03:41 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Except you can't really use that trigger because there are ways to bypass it.
If you make changes and the exit the form (or clear the blocks, or execute a query) then forms will ask you if you want to save changes. If you click yes forms will commit the changes without firing key commit.
Re: Trigger on save button?? [message #600166 is a reply to message #600133] Fri, 01 November 2013 12:22 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Right, the good old dilemma ... It means that someone who wants to utilize KEY-COMMIT should take care about actions Cookiemonster mentioned (clearing blocks, exiting a form) and create appropriate triggers with appropriate code. For example:
-- KEY-CLRBLK trigger
CLEAR_BLOCK(NO_VALIDATE);
or
-- KEY-EXIT
EXIT_FORM(DO_COMMIT);
etc. etc. That looks rather inappropriate - you have to take care about many things.

Is there an easy way out?
Re: Trigger on save button?? [message #600191 is a reply to message #600166] Fri, 01 November 2013 19:20 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Design your form so do don't need to do anything on save.
Re: Trigger on save button?? [message #600196 is a reply to message #600191] Sat, 02 November 2013 11:20 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Could you rewrite it? I'm kind of lost in these do-don't-do stuff.
Re: Trigger on save button?? [message #600250 is a reply to message #600196] Mon, 04 November 2013 05:44 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Not really, what I'm suggesting is too wide ranging and generic to give code examples.
Bottom line is - if your form design relies on validating or modifying data when the user clicks on save you need to change your form design - not change some code to get around this, but change the business process of how the form is to be used so it's not necessary in the first place.

Of course this assumes you can't actually do what is necessary in when-validate-record or the pre/post-insert/update/delete triggers. If those work they would be the first choice.
Re: Trigger on save button?? [message #600251 is a reply to message #600250] Mon, 04 November 2013 06:45 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
So you did rewrite it! Thank you!

I was referring to your previous message:CM

Design your form so do don't need to do anything on save.
Red are these do-don't-dos
Re: Trigger on save button?? [message #600252 is a reply to message #600251] Mon, 04 November 2013 07:07 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
that first "do" should have been a "you".
Re: Trigger on save button?? [message #600258 is a reply to message #600252] Mon, 04 November 2013 08:31 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
Dear do just do this

create table test1(item_no varchar2(6),item_name varchar2(20),qty number(8));

create table stock(item_no varchar2(6),item_name varchar2(20),stock_qty number(8));


insert into TEST1 VALUES('001','XBOX',2);
insert into TEST1 VALUES('002','PLAYSTATION',5);
insert into TEST1 VALUES('003','LED TV',10);

insert into stock VALUES('001','XBOX',10);
insert into stock VALUES('002','PLAYSTATION',50);
insert into stock VALUES('003','LED TV',80);

COMMIT;


after call test1 in the form make one button and write simple

begin
     go_block('test1');
      first_record;
     while :qty is not null loop
           update STOCK set STOCK_QTY=(select STOCK_QTY+:QTY from STOCK
           where ITEM_NO=:ITEM_NO)where ITEM_NO=:ITEM_NO;
     next_record;
    end loop;
       MESSAGE('TRANSACTION SAVED AND UPDATED ANOTHER TABLE WHICH IS NOT IN DATA BLOCK');
       MESSAGE('TRANSACTION SAVED AND UPDATED ANOTHER TABLE WHICH IS NOT IN DATA BLOCK');
       commit;
FIRST_RECORD;       
end;


OK take this FMB file it will be more easy for you.

Regard
Mughal









[Updated on: Mon, 04 November 2013 08:32]

Report message to a moderator

Re: Trigger on save button?? [message #600259 is a reply to message #600133] Mon, 04 November 2013 08:37 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
How does adding a button improve matters?
That relies on users remembering to press it.
Re: Trigger on save button?? [message #600261 is a reply to message #600259] Mon, 04 November 2013 08:44 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
DEAR Read the question ABOVE Standard "SAVE" button otherwise you can do this put this code in FORM-LEVEL-TRIGGER-PRE-COMMIT and when you are gonna save records just put below "clear_block(do_commit) and remember removed commit from this code and dear one more think, one by one you can also save records by using key_next-item or whatever trigger suits you but you have to removed loop from this code


clear_block(do_commit);

Regard
Mughal

[Updated on: Mon, 04 November 2013 08:51]

Report message to a moderator

Re: Trigger on save button?? [message #600263 is a reply to message #600261] Mon, 04 November 2013 08:51 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
What makes you think I haven't read the question?
The answer was key-commit.
I pointed out why key-commit should never be used.

And you can't put the code in your post above in pre-commit, it doesn't allow unrestricted built-ins.
Re: Trigger on save button?? [message #600264 is a reply to message #600263] Mon, 04 November 2013 08:57 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
DEAR read my i said one by one records when you wanna saved

PRE-COMMIT-----tRIGGER
update STOCK set STOCK_QTY=(select STOCK_QTY+:QTY from STOCK where ITEM_NO=:ITEM_NO)where ITEM_NO=:ITEM_NO;

Key-next-item---whatever suits you

clear_block(do_commit);

Re: Trigger on save button?? [message #600266 is a reply to message #600264] Mon, 04 November 2013 09:10 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
Frnd take this PRE-COMMIT example

Regard
Mughal
Re: Trigger on save button?? [message #600267 is a reply to message #600264] Mon, 04 November 2013 09:14 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
mughals_king wrote on Mon, 04 November 2013 14:57
DEAR read my i said one by one records when you wanna saved

You put that in your update at the same time I was posting my reply, so I wasn't in a position to see it.

mughals_king wrote on Mon, 04 November 2013 14:57

PRE-COMMIT-----tRIGGER
update STOCK set STOCK_QTY=(select STOCK_QTY+:QTY from STOCK where ITEM_NO=:ITEM_NO)where ITEM_NO=:ITEM_NO;

That's not going to work - pre-commit fires once when you commit, not once per record.

mughals_king wrote on Mon, 04 November 2013 14:57

Key-next-item---whatever suits you

I sincerely hope that key-next-item doesn't suit anyone for this purpose. Having a form that tries to update another table every time a user tabs through a particular field strikes me as a really bad idea. Plus of course if they don't tab through but use the mouse to navigate instead, the update will never happen. Key-next-item should never be used for data modification or validation. People who rely on it end up with corrupted data.
The obvious place for such an update statement is pre-insert and pre-update.

mughals_king wrote on Mon, 04 November 2013 14:57

clear_block(do_commit);

No idea why you're mentioning this.
Re: Trigger on save button?? [message #600268 is a reply to message #600267] Mon, 04 November 2013 09:25 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
No dear i am not intentionally adding these things don't take personal, as far as concern KEY-NEXT-ITEM trigger i saw in your country central london when i went there your programmers designed for barcode reader device they were using KEY-NEXT-ITEM--->Trigger where barcode item was pointed the cursor that time automatic records was saving the record one by one. you can't say KEY-NEXT-ITEM--->triggger useless

and i am also using this trigger for barcode reader as well and its successfully working in largest reputed companies.


Regard
Mughal

[Updated on: Mon, 04 November 2013 09:28]

Report message to a moderator

Re: Trigger on save button?? [message #600269 is a reply to message #600268] Mon, 04 November 2013 09:31 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
and i am sorry if you feel bad why i uploaded this code i thought may be thery are using kind of device like barcode reader iam talking about pre-commit->trigger thats why i did this. may be i was wrong but that codes which i upload its 100% working both for pre-commit and Standard save button for different pur

Regard
Mughal

[Updated on: Mon, 04 November 2013 09:57]

Report message to a moderator

Re: Trigger on save button?? [message #600272 is a reply to message #600114] Mon, 04 November 2013 10:05 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
sanjlaxmi wrote on Thu, 31 October 2013 20:37
which is the trigger that fires when we Press the Standard 'Save' button from the toolbar?
and i want to update the record on another table which is not in data block by using this save button?
@ that time i want to display message like transaction complete:1 records saved..how to do this??

pls help me to find out solution..
thanx.


Dear close this chapter, we are not here for any debate we are here to helping the peoples who need our help i respect all those who use this forum for help or gurus who provides the solutions. i am sorry again if you feel bad i personally request to you pls read this question may be i have had mis-interpreted this question.

Regard
Mughal

[Updated on: Mon, 04 November 2013 10:14]

Report message to a moderator

Re: Trigger on save button?? [message #600275 is a reply to message #600272] Mon, 04 November 2013 10:31 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
mughals_king wrote on Mon, 04 November 2013 16:05

Dear close this chapter, we are not here for any debate we are here to helping the peoples who need our help

And why is debating how forms works mutually exclusive to helping people?

mughals_king wrote on Mon, 04 November 2013 16:05

i am sorry again if you feel bad

I don't feel bad at all, I'm just pointing out why I think your suggestions won't work. This is part of how forums work - people make suggestions, if there are problems with them other people point those problems out.

mughals_king wrote on Mon, 04 November 2013 16:05

i personally request to you pls read this question

I've already pointed out that I've read the question, if you think I've overlooked something you need to point out what that is. I certainly see no evidence the OP is using a bar-code reader. Obviously it would help if they stated why they are trying to do what they've asked for.


As for pre-commit. I don't have a working forms instalation handy to test it but the documentation is very clear - pre-commit fires once when you commit.
So have you tested it for a multi-record block with multiple records being modified before clicking on save? Because I'll be amazed if it works properly in those circumstances.

The documentation also states this:
Quote:

Note: If you perform DML in a Pre-Commit trigger and the trigger fails, you must perform a manual
rollback, because Forms Developer does not perform an automatic rollback. To prepare for a
possible manual rollback, save the savepoint name in an On-Savepoint trigger, using
GET_APPLICATION_PROPERTY (Savepoint_Name). Then you can roll back using
ISSUE_ROLLBACK (Savepoint_Name).

Which would make me really nervous of putting updates in it.

As for key-next-item - it might be ok for a form connected to a bar-code scanner with no mouse connected, but for a standard web-form it should only be used for navigation code, which is why it exists, if you use it to update data then sooner or later the data won't get updated when it should.
Re: Trigger on save button?? [message #600298 is a reply to message #600275] Mon, 04 November 2013 13:59 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
cookiemonster wrote on Mon, 04 November 2013 10:31

so have you tested it for a multi-record block with multiple records being modified before clicking on save? Because I'll be amazed if it works properly in those circumstances.

cookiemonster wrote on Mon, 04 November 2013 10:31

Which would make me really nervous of putting updates in it.

cookiemonster wrote on Mon, 04 November 2013 10:31

standard web-form


Dear i never mention in my previous posts that pre-commit will work for multi-record block. nor i discussed about web-form
if you are pointing my code which i have posted above for updation it is properly and 100% working on button pressed you can check whenever you want that's why i uploaded my fmb file with tables anyway take care.

Regard
Mughal Cool

[Updated on: Mon, 04 November 2013 14:07]

Report message to a moderator

Re: Trigger on save button?? [message #600313 is a reply to message #600298] Mon, 04 November 2013 17:17 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
mughals_king wrote on Mon, 04 November 2013 19:59

Dear i never mention in my previous posts that pre-commit will work for multi-record block.

a) You originally suggested putting code that looped over the block in pre-commit.
b) If you've got a solution that only works for a subset of forms you need to make that clear.

mughals_king wrote on Mon, 04 November 2013 19:59

nor i discussed about web-form

So? They do not behave any differently in this regard from client-server.

mughals_king wrote on Mon, 04 November 2013 19:59

if you are pointing my code which i have posted above for updation it is properly and 100% working on button pressed

I imagine it does work in when-button-pressed and if the users remember to click on the button then great, if they don't though you have a problem.
Re: Trigger on save button?? [message #600362 is a reply to message #600313] Tue, 05 November 2013 06:21 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
Frnd still you need to learn lot of things in programming fields. I am always learner and will be i always try to learn from new things i learnt a lot from this forum & i don't have any problem to learn more & more.


Regard
Mughal
Re: Trigger on save button?? [message #600364 is a reply to message #600362] Tue, 05 November 2013 07:04 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
What on earth was the point of that statement?

You've made some suggestions. I've pointed out technical reasons why I think they're not generally a good idea based on verifiable facts of how forms works.
That's not an argument from authority, that's an argument from fact.
If you think I've missed some relevant facts, by all means point them out.

I know you know a fair bit about forms from your posts here, but that does not change how pre-commit and key-next-item work.
Previous Topic: Validate Item value in multiple records
Next Topic: upload file using oracle 11g forms
Goto Forum:
  


Current Time: Fri Apr 26 01:25:33 CDT 2024