inserting multiple rows using a data block [message #329960] |
Fri, 27 June 2008 02:31 |
hammad83
Messages: 46 Registered: June 2008 Location: Australia
|
Member |
|
|
Hi all
I want to insert multiple rows in a table using a data block which is not a database block. I want to insert every row entered in the data block in a table. But when I commit it only saves the last row entered. I put that into a loop like this.
for j in 0 .. 50 loop
insert into .....
end loop;
standard.commit;
When I do that it inserts 51 empty rows in the table but does not insert any value that I insert into the data block. If I do not put it into loop it only saves the last record. Can anyone help me with that?
Thanks
Hammad
|
|
|
|
|
|
Re: inserting multiple rows using a data block [message #330003 is a reply to message #329960] |
Fri, 27 June 2008 04:55 |
hammad83
Messages: 46 Registered: June 2008 Location: Australia
|
Member |
|
|
Sorry for the confusion guys. I will try to explain it more now.
I have a form in which there is a data block displaying more than one record. It means that this data block is in tabular form and I want that whatever is inserted in that data block is saved in a table named RDATA in ADMIN schema. Now the data block name is RETURNS and there are three text items in it, CODE, DESCRIPTION and AMOUNT.
Then I have a SAVE button to save the record. The code is like this.
go_block('returns');
insert into admin.rdata
values(:returns.code, :returns.description, :returns.amount);
standard.commit;
message('Record Saved');
Now I insert record into these three items. For example 3333, Tax Paid, 83884. After that I insert another record. 9999, Net Tax, 100000. Then another, for example, 3455, Gross Tax, 34553. (The three values are for code, description and amount respectively in the data block returns). NOW the problem is that in the table rdata only the last record is saved i.e. 3455, Gross Tax, 34553 and the records inserted before that are not saved. To give it another try I added a loop in my code. i.e.
go_block('returns');
for j in 0..50 loop
insert into admin.rdata
values(:returns.code, :returns.description, :returns.amount);
end loop;
standard.commit;
message('Record Saved');
When I do that it inserts 51 empty rows in the table and no record inserted in the data block is saved.
I also tried to put the next_record in the loop like this.
go_block('returns');
for j in 0..50 loop
insert into admin.rdata
values(:returns.code, :returns.description, :returns.amount);
next_record;
end loop;
standard.commit;
message('Record Saved');
But when I click on SAVE button it says "Record must be entered or deleted first".
I hope the problem is more clear now.
Thanks.
Hammad
|
|
|
|