Home » Developer & Programmer » Forms » inserting multiple rows using a data block (Oracle 8i, Developer 6i, Windows 2000)
inserting multiple rows using a data block [message #329960] Fri, 27 June 2008 02:31 Go to next message
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 #329962 is a reply to message #329960] Fri, 27 June 2008 02:37 Go to previous messageGo to next message
varu123
Messages: 754
Registered: October 2007
Senior Member
Not clear what are you ttrying to say?
WHat data block is it if not oracle one?
WHat is standard.commit?
Re: inserting multiple rows using a data block [message #329963 is a reply to message #329960] Fri, 27 June 2008 02:38 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I'm afraid I can't understand what you're trying to say.
Can you post your code, and the results of a couple of SQL queries showing what the problem is.
Re: inserting multiple rows using a data block [message #329977 is a reply to message #329960] Fri, 27 June 2008 03:16 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This:
Quote:
for j in 0 .. 50 loop

insert into .....

end loop;

standard.commit;

means nothing. What do you insert? Is it contents of forms' block items? Did you navigate to the next record? How do you know there are ~50 "empty" records? What is an "empty" record?

This is one of the vaguest questions lately. Please, make some additional effort and explain WHAT you are trying to do and HOW (which means that code you post should be much more than "INSERT INTO ...").

Also, read OraFAQ Forum Guide which will teach you how to properly format your message.
Re: inserting multiple rows using a data block [message #330003 is a reply to message #329960] Fri, 27 June 2008 04:55 Go to previous messageGo to next message
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
Re: inserting multiple rows using a data block [message #337147 is a reply to message #330003] Wed, 30 July 2008 01:13 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have you solved your problem? How many rows are there in your block?

David
Previous Topic: getting error message while debugging form
Next Topic: Calling webutil functions from a library
Goto Forum:
  


Current Time: Fri Dec 06 16:54:34 CST 2024