Home » Developer & Programmer » Forms » Logic for EDIT button (Oracle Developer Suite 10g,Win 7 Professional 64 bit)
Logic for EDIT button [message #641899] Thu, 27 August 2015 01:31 Go to next message
shumail
Messages: 149
Registered: September 2012
Location: Canada
Senior Member
Hi

I really appreciate if some one guide me what should be the code on when button Pressed trigger for Edit purpose...

In my scenario, I have a field in which I have to enter name and if I enter some input in this field and press EDIT button then it shows data against that name and other info in separate window and allow for modification .....I appreciate if someone send me some sample code so that I can view it and change it accordingly. Thanks
Re: Logic for EDIT button [message #641900 is a reply to message #641899] Thu, 27 August 2015 01:40 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That "separate window" would contain a new data block, containing all items related to selected name. Button trigger would just
GO_ITEM('new_block.its_first_item');


However, why making thins complicated? Use only one data block created by the Data Block Wizard. Perform query (enter query -> enter name -> execute query) and view or update information related to that name. That's by far the simplest way to do anything you want (which includes inserting new records as well as deleting existing ones).
Re: Logic for EDIT button [message #641913 is a reply to message #641900] Thu, 27 August 2015 08:33 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Forms has a built-in editor...why not just invoke that? For example:
BEGIN
  Go_Item('Your Text Item to Edit');
  Edit_TextItem(Get_Item_Property(:SYSTEM.CURSOR_ITEM,X_POS),Get_Item_Property(:SYSTEM.CURSOR_ITEM,Y_POS), 20, 8);    
END;

You should specify the X/Y coordinate to display the editor (first two arguments) and you should specify the Height and Width (last two arguments) for the default editor. For more information about this Built-in, please check the Forms Help Topic...

Craig...
Re: Logic for EDIT button [message #641918 is a reply to message #641913] Thu, 27 August 2015 09:12 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
Sounds like they want more than just the current item in the pop-up window so the editor wouldn't be much use.
Re: Logic for EDIT button [message #641922 is a reply to message #641918] Thu, 27 August 2015 10:12 Go to previous messageGo to next message
shumail
Messages: 149
Registered: September 2012
Location: Canada
Senior Member
Hi Craig

Cookiemonster is right...
Re: Logic for EDIT button [message #641945 is a reply to message #641922] Thu, 27 August 2015 18:07 Go to previous messageGo to next message
shumail
Messages: 149
Registered: September 2012
Location: Canada
Senior Member
Hi
I tried it but I'm getting pop up like do you want to save changes you have made, but the funny thing is that I didn't perform any changes and still getting this save popup....
I wrote the following code in Edit (When button pressed trigger...
SHOW_WINDOW('ROLE');
:ROLE_MAINTENANCE.ROLE_NAME := :ROLE_SEARCH_RESULTS.ROLE_NAME;
go_block('ROLE_MAINTENANCE');
execute_query;


don't know why I'm getting this popup and don't know how to identify it...
Re: Logic for EDIT button [message #641947 is a reply to message #641945] Fri, 28 August 2015 00:09 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:

I didn't perform any changes and still getting this save popup

Didn't you enter name into the ROLE_NAME item? Wouldn't that be a modification? Is ROLE_SEARCH_RESULTS a data block, or a control block?
Re: Logic for EDIT button [message #641973 is a reply to message #641947] Fri, 28 August 2015 09:39 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Littlefoot is correct. By setting :ROLE_MAINTENACE.ROLE_NAME to the value of :ROLE_SEARCH_RESULTS.ROLE_NAME you have changed the status of the block. So, when you call Execute_Query(), Forms wants to know if you want to save the change before it clears the block and executes the query. In your example, you are going to get all of the records from the table behind the ROLE_MAINTENANCE block.
SHOW_WINDOW('ROLE');
:ROLE_MAINTENANCE.ROLE_NAME := :ROLE_SEARCH_RESULTS.ROLE_NAME;
...

This is wrong. Do you want :ROLE_SEARCH_RESULTS.ROLE_NAME to be the search criteria for the ROLE_MAINTENANCE block? If yes, then you have 2 options.
1st - Show your Window, Navigate to the ROLE_MAINTENANCE block and put the block into Query Mode. THEN assign :ROLE_MAINTENANCE.ROLE_NAME equal to :ROLE_SEARCH_RESULTS.ROLE_NAME and lastly call Execute_Query.
or
2nd, you need to set the DEFAULT_WHERE clause of your ROLE_MAINTENANCE block before you call Execute_Query. For example:
/* Option 1 */
SHOW_WINDOW('ROLE');
GO_BLOCK('ROLE_MAINTENANCE');
ENTER_QUERY;
:ROLE_MAINTENANCE.ROLE_NAME := :ROLE_SEARCH_RESULTS.ROLE_NAME;
execute_query;

/* Option 2 */
SHOW_WINDOW('ROLE');
GO_BLOCK('ROLE_MAINTENANCE');
-- Assuming you are using Forms 10g or higher...
Set_Block_Property('ROLE_MAINTENANCE', ONETIME_WHERE,'ROLE_NAME = '''||:ROLE_SEARCH_RESULTS.ROLE_NAME||''');
-- If you are NOT using Forms 10g or higher then...
Set_Block_Property('ROLE_MAINTENANCE', DEFAULT_WHERE,'ROLE_NAME = '''||:ROLE_SEARCH_RESULTS.ROLE_NAME||''');
execute_query;

The above code samples are untested and may need changes in order to work...

Craig...

[Updated on: Fri, 28 August 2015 09:40]

Report message to a moderator

Re: Logic for EDIT button [message #641992 is a reply to message #641973] Fri, 28 August 2015 14:34 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I'd say that Option 1 won't work that way. Once the form enters into query mode, it just waits until query is actually executed (or cancelled), so
:ROLE_MAINTENANCE.ROLE_NAME := :ROLE_SEARCH_RESULTS.ROLE_NAME;
won't be executed until one of the previous two options takes place. I'd rewrite it as
-- WHEN-BUTTON-PRESSED
SHOW_WINDOW('ROLE');
GO_BLOCK('ROLE_MAINTENANCE');
EXECUTE_QUERY;

-- PRE-QUERY trigger
:ROLE_MAINTENANCE.ROLE_NAME := :ROLE_SEARCH_RESULTS.ROLE_NAME;


Though, I prefer setting ONETIME_WHERE (or DEFAULT_WHERE) as PRE-QUERY is somewhat more difficult to debug as code logic goes from one trigger (WHEN-BUTTON-PRESSED) to another one (PRE-QUERY) so you have to review code in different program units. Not that it is impossible, it's just not that straightforward.
Re: Logic for EDIT button [message #642011 is a reply to message #641992] Sat, 29 August 2015 20:37 Go to previous message
shumail
Messages: 149
Registered: September 2012
Location: Canada
Senior Member
Thanks for the replies and I really appreciate that you provide me such a valuable info...
Previous Topic: commit_form is not working in Called Form
Next Topic: TEXT_IO NOT WORKING FOR ALL USERS
Goto Forum:
  


Current Time: Fri Mar 29 10:14:55 CDT 2024