Home » Developer & Programmer » Forms » How to Insert Records Which are Checked in Multi Record Block
How to Insert Records Which are Checked in Multi Record Block [message #513792] Wed, 29 June 2011 07:28 Go to next message
goparaju
Messages: 54
Registered: June 2011
Member
Hi Experts,

I am working on forms 6i.

I have datablock 'EMP', it's multi record block. I have a button 'CREATE', I have 'commit_form' in 'When button pressed' trigger, to commit records. It's working fine.

Now, i have a check box in the same block, i want to insert records which are checked only. Could anybody help me how to get this.

Thanks in advance.



Re: How to Insert Records Which are Checked in Multi Record Block [message #513796 is a reply to message #513792] Wed, 29 June 2011 08:00 Go to previous messageGo to next message
cookiemonster
Messages: 13952
Registered: September 2008
Location: Rainy Manchester
Senior Member
You would have to create a button. In it's when-button-pressed trigger you would write some code to loop over the datablock using first_record/next_record and insert each record that is checked with an insert statement.
You would need to make the block a non-database block otherwise commit_form will cause all the other records to be inserted anyway.
Re: How to Insert Records Which are Checked in Multi Record Block [message #513806 is a reply to message #513796] Wed, 29 June 2011 08:33 Go to previous messageGo to next message
goparaju
Messages: 54
Registered: June 2011
Member
Hi,
Thanks for your reply. If i make it non database block, i want query mode(F11) should work for that block. For non database block, will F11 work automatically,or do i need to write any code.

Kindly help.

Thanks
Re: How to Insert Records Which are Checked in Multi Record Block [message #513809 is a reply to message #513806] Wed, 29 June 2011 08:42 Go to previous messageGo to next message
cookiemonster
Messages: 13952
Registered: September 2008
Location: Rainy Manchester
Senior Member
You'll need to write code. and enter-query mode won't work. Non of the default processing works on non-database blocks.
And if the user exits the form it won't ask if they want to save changes.

There is one alternative - base the block on a procedure. You can have an insert procedure that takes all the items in the block and it can do an insert or not based on the value of the checkbox.
This also involves a lot of code but you'll get enter-query and asking to save on exit back.
Re: How to Insert Records Which are Checked in Multi Record Block [message #513814 is a reply to message #513809] Wed, 29 June 2011 08:55 Go to previous messageGo to next message
Littlefoot
Messages: 21821
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Or, alternatively, let it be as it is now (database block, COMMIT_FORM you are satisfied with). Check checkboxes you want. Now, in WHEN-BUTTON-PRESSED trigger (you mentioned in your first message) do the opposite - loop through all records in a form, and DELETE records (from the database) that are not checked.
Re: How to Insert Records Which are Checked in Multi Record Block [message #513815 is a reply to message #513814] Wed, 29 June 2011 08:57 Go to previous messageGo to next message
cookiemonster
Messages: 13952
Registered: September 2008
Location: Rainy Manchester
Senior Member
I can think of a few ways that can break.
Most obvious:
User creates set of records and checks some of them.
User clicks on exit.
Form asks "Do you want to save changes"
User clicks Yes.
All records are inserted by default processing, none are deleted.
Re: How to Insert Records Which are Checked in Multi Record Block [message #513860 is a reply to message #513814] Wed, 29 June 2011 13:41 Go to previous messageGo to next message
goparaju
Messages: 54
Registered: June 2011
Member
Hi Experts,

Thanks for your replies. Before main screen(EMP BLOCK) screen, i have 'FIND' window, which contains empno, ename. When i click FIND button, it will fetch data from EMP1 table (which of same structure of EMP table) and populates data in EMP block.

Now i will check records which ever needed,after clicking 'SUBMIT' button, only checked records should be inserted into EMP table.


If i follow to delete the unchecked records and click submit button, will it insert only checked records? In that case,as one of the replies mentioned that without clicking submit button if user clicks close window and 'save changes' yes, will it insert all records?

Could somebody provide me the feasible solution.

Thanks for your support.

Awaiting your responses.

Re: How to Insert Records Which are Checked in Multi Record Block [message #513871 is a reply to message #513860] Wed, 29 June 2011 14:47 Go to previous message
cookiemonster
Messages: 13952
Registered: September 2008
Location: Rainy Manchester
Senior Member
I did provide a feasible solution, 2 in fact.
1) Make the block a non-database block. Code a button to insert the records. Code another button to query records
2) Base the block on a procedure.

2 is more work but gives a better user experience.
Previous Topic: dependent lov in forms
Next Topic: Reports Problem in 10g
Goto Forum:
  


Current Time: Fri Nov 08 15:20:40 CST 2024