Home » Developer & Programmer » Forms » Inserting more than one record
Inserting more than one record [message #132527] Sat, 13 August 2005 23:29 Go to next message
samit_gandhi
Messages: 226
Registered: July 2005
Location: Hong Kong
Senior Member

Dear Sir,

I have created the master-detail form for my application. I also want to insert the details record in one another table i.e. other than the detail table. But when i write the insert query at the time of commit_form(). it is inserting only a last record. I want to insert all the records of the detail block.

How to do it?? Please reply asap.

Samit Gandhi
Re: Inserting more than one record [message #132570 is a reply to message #132527] Sun, 14 August 2005 21:24 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I believe that you have your trigger at the form level, try moving it down to the block level. Then it will fire for each record.

David
Re: Inserting more than one record [message #132574 is a reply to message #132570] Sun, 14 August 2005 21:31 Go to previous messageGo to next message
samit_gandhi
Messages: 226
Registered: July 2005
Location: Hong Kong
Senior Member

Dear David,

At form level i have only one trigger on-clear-detail. My problem is when i save the record master detail form whatever the records in the detail block must be save in detail table as well as on the another one table. Further i have more than one record in detail block. so all the detail blocks record must be saved in another table.

See i have one master table
purchase_master

one detail table
purchase_detail

another table
inventory_detail

I have one form having the master table purchase_master and detail table having record show facility of 5 records.

Now when i save the records suppose i have 2 records inserted against one invoice no in detail block at that time 2 records must be inserted in purchase_detail table as well as inventory_detail table.

Please explain me taking the example pls it is very urgent. I am hang up due to this.

Samit Gandhi
Re: Inserting more than one record [message #132575 is a reply to message #132574] Sun, 14 August 2005 21:36 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay then your insert code sounds as though it is on the master block. It needs to be on the detail block.

Please reply with the names of the triggers you have for each block. Please indicate which trigger contains the insert code for the extra table.

Please reread your previous reply and detail which table is addressed by your detail block and which table is the 'extra'.

David
Re: Inserting more than one record [message #132577 is a reply to message #132575] Sun, 14 August 2005 21:44 Go to previous messageGo to next message
samit_gandhi
Messages: 226
Registered: July 2005
Location: Hong Kong
Senior Member

Dear David,

I have one master detail form named Metal_Purchase
The form level trigger is :
On-Clear_Detail

The first block is master block name metal_purchase_master

The block belongs to the table metal_purchase_master.

The block level trigger is :

ON-POPULATE-DETAILS
ON-CHECK-DELETE-MASTER

And relation ship of master-detail.

The second block is detail blcok name metal_purchase_detail
The block belongs to the table metal_purchase_detail.

The block level trigger is : (no trigger)

The third block is Control block in which there are some buttons for new, save, exit, clear etc. it is not a database block.

Now i want to insert the record in inventory_detail when the user press the save button. This is an extra table. The records for inventory_detail is the record of metal_purchase_detail table.

How to do it. I hope u can understand my problem now.

Please give the reply immediately. I am waiting for your reply.

Samit Gandhi


Re: Inserting more than one record [message #132578 is a reply to message #132577] Sun, 14 August 2005 21:52 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay.

Master table: metal_purchase_master

Detail table: metal_purchase_detail

Extra table: inventory_detail

I believe your current logic has the insert statement for inventory_detail in the When-Button-Pressed trigger associated with the Save button. Move this logic to a Post-Insert trigger on your metal_purchase_detail block. This wya, each time a record is inserted into the metal_purchase_detail table the trigger will fire and a record will be inserted into the inventory_detail table.

Do you have to handle updates as well? Have you thought of putting the logic into a database trigger on the metal_purchase_detail table?

David
Re: Inserting more than one record [message #132579 is a reply to message #132578] Sun, 14 August 2005 22:10 Go to previous messageGo to next message
samit_gandhi
Messages: 226
Registered: July 2005
Location: Hong Kong
Senior Member

Dear David,

I also have to handle the update operation.

Samit Gnadhi
Re: Inserting more than one record [message #132581 is a reply to message #132579] Sun, 14 August 2005 22:18 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Then you use a Post-Update trigger. Make sure that you only update the record that needs to be updated.

David

[Updated on: Sun, 14 August 2005 22:30]

Report message to a moderator

Re: Inserting more than one record [message #132582 is a reply to message #132527] Sun, 14 August 2005 22:24 Go to previous messageGo to next message
samit_gandhi
Messages: 226
Registered: July 2005
Location: Hong Kong
Senior Member

Dear David,

In this case whenever an issue is done the table inventory_detail is updated by that quantity and whenever new purchase is done the inventory_detail is updated by that quantity what i have to do for that.

Samit Gandhi
Re: Inserting more than one record [message #132583 is a reply to message #132582] Sun, 14 August 2005 22:33 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
In inventory_detail, do you insert a new record when you insert a new record into metal_purchase_detail or do you increase the value of a field in inventory_detail. That is, does inventory_detail match recrod to record with metal_purchase_detail or does it hold the 'sum' of the values?

David
Re: Inserting more than one record [message #132584 is a reply to message #132583] Sun, 14 August 2005 22:55 Go to previous messageGo to next message
samit_gandhi
Messages: 226
Registered: July 2005
Location: Hong Kong
Senior Member

It is summing the value and not new inserting into inventory_detail table whenever the new purchase is done.

Samit Gandhi
Re: Inserting more than one record [message #132585 is a reply to message #132584] Sun, 14 August 2005 23:00 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay ... then 'add' on an insert and 'add' new, 'subtract' existing value when updating.

David
Previous Topic: User_Exit in Forms9i Linux
Next Topic: how to make this type of tlist/poplist???
Goto Forum:
  


Current Time: Fri Sep 20 04:42:13 CDT 2024