Home » Developer & Programmer » Forms » How to update record in database using functional key?
How to update record in database using functional key? [message #665760] Wed, 20 September 2017 03:35 Go to next message
mashhoodnasir
Messages: 26
Registered: May 2017
Junior Member
Hey guyz. I have a data_block:ABC. i am using different buttons for different purpose with their functional keys and triggers. for e.g.
Button Name: Save, trigger:When-Button-Pressed, query: DO-KEY('COMMIT_FORM');
Trigger at Form used:Key-Commit
all the buttons are working perfectly except UPDATE button.
Button Name: UPDATE, trigger:WHEN-BUTTON-PRESSED, query: DO-KEY('LOCK_RECORD');
Trigger at Form used:KEY-UPDREC

do i need to use UPDATE-Statement? if yes then which trigger to choose.
please guide me.
Re: How to update record in database using functional key? [message #665762 is a reply to message #665760] Wed, 20 September 2017 04:04 Go to previous messageGo to next message
cookiemonster
Messages: 12927
Registered: September 2008
Location: Rainy Manchester
Senior Member
Why are you using any of these?
Why aren't you using the forms default functionality?
Re: How to update record in database using functional key? [message #665764 is a reply to message #665762] Wed, 20 September 2017 04:24 Go to previous messageGo to next message
Littlefoot
Messages: 21235
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
+1

When updating values, you want to save those changes into the database, right? If so, it means that your UPDATE button should do exactly the same as your SAVE button (i.e. commit).
Re: How to update record in database using functional key? [message #665765 is a reply to message #665764] Wed, 20 September 2017 04:28 Go to previous messageGo to next message
mashhoodnasir
Messages: 26
Registered: May 2017
Junior Member
then what is the purpose of Trigger:KEY-UPDREC or LOCK_RECORD?
Re: How to update record in database using functional key? [message #665766 is a reply to message #665762] Wed, 20 September 2017 04:30 Go to previous messageGo to next message
mashhoodnasir
Messages: 26
Registered: May 2017
Junior Member
@cookiemonster Which functionality you are talking about?
Re: How to update record in database using functional key? [message #665769 is a reply to message #665766] Wed, 20 September 2017 05:06 Go to previous messageGo to next message
cookiemonster
Messages: 12927
Registered: September 2008
Location: Rainy Manchester
Senior Member
save, lock, update, exit.....
Anything forms does as standard.
Re: How to update record in database using functional key? [message #665771 is a reply to message #665765] Wed, 20 September 2017 06:10 Go to previous messageGo to next message
Littlefoot
Messages: 21235
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
mashhoodnasir wrote on Wed, 20 September 2017 11:28
then what is the purpose of Trigger:KEY-UPDREC or LOCK_RECORD?
The fact that they exist doesn't mean that you must use them.

Note that some triggers are there just for backward compatibility (dated since character mode Forms version) and shouldn't be used any more because their functionality is replaced with some other triggers. A few examples: POST-CHANGE which should be replaced with POST-QUERY. Or, KEY-NEXT-ITEM with WHEN-VALIDATE-ITEM.

For more info about those triggers (or anything you're interested in), open Forms Help system, search & read.
Re: How to update record in database using functional key? [message #665778 is a reply to message #665771] Wed, 20 September 2017 07:59 Go to previous messageGo to next message
cookiemonster
Messages: 12927
Registered: September 2008
Location: Rainy Manchester
Senior Member
A lot of triggers exist so you can change forms default functionality if necessary. But it rarely is necessary.

The only triggers I used regularly are:
the validate triggers
pre-insert/update/delete
pre/post-query
when-button-pressed
when-new-item/record/block/form-instance

@LF - when-validate shouldn't replace key-next. But a lot of people coded validation code into key-next when it should have been in the validate triggers. Sometimes you want to do non-standard navigation and then you need key-next.
Re: How to update record in database using functional key? [message #665796 is a reply to message #665778] Wed, 20 September 2017 14:42 Go to previous messageGo to next message
Littlefoot
Messages: 21235
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What I meant to say was that you had to do validation in KEY-NEXT-ITEM trigger because WHEN-VALIDATE-ITEM didn't exist. Nowadays, you'd use WHEN-VALIDATE-ITEM, not KEY-NEXT-ITEM for validation.
Re: How to update record in database using functional key? [message #665802 is a reply to message #665796] Wed, 20 September 2017 23:46 Go to previous messageGo to next message
mashhoodnasir
Messages: 26
Registered: May 2017
Junior Member
It depend on the situation which trigger we use. For me KEY-NEXT-ITEM work better than WHEN-VALIDATE-ITEM for validation purpose.
by the way @CM & @LF i am very much thankful for your precious advice.
Re: How to update record in database using functional key? [message #665805 is a reply to message #665802] Thu, 21 September 2017 03:33 Go to previous messageGo to next message
cookiemonster
Messages: 12927
Registered: September 2008
Location: Rainy Manchester
Senior Member
No it doesn't.
What if the user uses the mouse to move to another item?
Or up?
Or down?
Or shift-tab?
Or just hits save without moving to another item at all?

Never use key-next-item for anything other than navigation.
Re: How to update record in database using functional key? [message #665837 is a reply to message #665805] Mon, 25 September 2017 23:34 Go to previous messageGo to next message
mashhoodnasir
Messages: 26
Registered: May 2017
Junior Member
@Cookiemonster then which trigger should i use? because in my scenario if empno is already exist then system wont allow me to move to the next item and i am doing it by using KEY-NEXT-TRIGGER. i also tried with WHEN-VALIDATE-ITEM mouse navigation is stopped.

TRIGGER:KEY-NEXT-ITEM
SELECT EMPNO INTO :EMPNO FROM ABC WHERE EMPNO=:EMPNO;
MESSAGE('ALREADY EXIST');
MESSAGE('ALREADY EXIST');
RAISE FORM_TRIGGER_FAILURE;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
NEXT_ITEM;
Re: How to update record in database using functional key? [message #665842 is a reply to message #665837] Tue, 26 September 2017 02:08 Go to previous messageGo to next message
Littlefoot
Messages: 21235
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This job should be done by WHEN-VALIDATE-ITEM trigger. Code you used is exactly the same - you'd just omit NEXT_ITEM call. If validation succeeds, Forms will navigate to the next item anyway.
Re: How to update record in database using functional key? [message #665844 is a reply to message #665760] Tue, 26 September 2017 03:00 Go to previous messageGo to next message
reachiso
Messages: 1
Registered: September 2017
Junior Member
We can use the update or insert buttons to do this task.
Re: How to update record in database using functional key? [message #665846 is a reply to message #665842] Tue, 26 September 2017 03:02 Go to previous messageGo to next message
cookiemonster
Messages: 12927
Registered: September 2008
Location: Rainy Manchester
Senior Member
I wouldn't select empno.
You shouldn't have triggers modify data-block items unnecessarily.
Select null into a local variable.
Re: How to update record in database using functional key? [message #665852 is a reply to message #665846] Tue, 26 September 2017 05:45 Go to previous messageGo to next message
mashhoodnasir
Messages: 26
Registered: May 2017
Junior Member
@LF yes you are right if validation succeed cursor move to the next item. but what to do if i want to move to the exit button without entering any record? because WHEN-VALIDATE-ITEM wont allow me to move to the exit button either using mouse or keyboard until successful validation.
Re: How to update record in database using functional key? [message #665853 is a reply to message #665846] Tue, 26 September 2017 05:49 Go to previous messageGo to next message
Littlefoot
Messages: 21235
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Yes, I agree & apologize for posting stupid answers. It appears that I'm not good at multitasking; didn't even notice what SELECT was doing. Sorry again.
Re: How to update record in database using functional key? [message #665854 is a reply to message #665852] Tue, 26 September 2017 05:49 Go to previous messageGo to next message
cookiemonster
Messages: 12927
Registered: September 2008
Location: Rainy Manchester
Senior Member
Have a look at the validation unit property.
That said - you should always be able to go to the exit button - have you created your own? If so, this is why you shouldn't. Just use the default toolbar.
Re: How to update record in database using functional key? [message #665860 is a reply to message #665854] Wed, 27 September 2017 00:31 Go to previous messageGo to next message
mashhoodnasir
Messages: 26
Registered: May 2017
Junior Member
@Cookiemonster yes i created my own exit button thats why i am failing to move to the button. i want to use the button i created rather than to use default toolbar. help me how to make this possible.
@LittleFoot why you are apologizing, we all are learners.
Re: How to update record in database using functional key? [message #665864 is a reply to message #665860] Wed, 27 September 2017 03:28 Go to previous messageGo to next message
cookiemonster
Messages: 12927
Registered: September 2008
Location: Rainy Manchester
Senior Member
Why do you want to use your own button?
Re: How to update record in database using functional key? [message #665893 is a reply to message #665864] Fri, 29 September 2017 00:12 Go to previous messageGo to next message
mashhoodnasir
Messages: 26
Registered: May 2017
Junior Member
because of the users requirement and i also want to analysis the behavior of single function with different method.http://www.orafaq.com/forum/r/frm_id/17/
Re: How to update record in database using functional key? [message #665899 is a reply to message #665893] Fri, 29 September 2017 06:33 Go to previous message
cookiemonster
Messages: 12927
Registered: September 2008
Location: Rainy Manchester
Senior Member
That really doesn't answer the question.
What user requirement?
What are you trying to analyse?
And I doubt that link goes where you think it does.
Previous Topic: oracle forms 6i running show in windows 10
Next Topic: Storing of an image into chart of products entry form in BLOB column of products table. (topics merged)
Goto Forum:
  


Current Time: Mon Nov 20 20:46:53 CST 2017

Total time taken to generate the page: 0.04227 seconds