Home » Developer & Programmer » Forms » Count rows of record inserted
Count rows of record inserted [message #154488] Mon, 09 January 2006 00:05 Go to next message
juicyapple
Messages: 92
Registered: October 2005
Member
I have create a form with several text field in tabular form. The form doesn't bind with database table.
How to count total rows of records inserted inside the fields?
Thanks.
Re: Count rows of record inserted [message #154492 is a reply to message #154488] Mon, 09 January 2006 00:45 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You'll have to walk through the block, something like this:
declare
  counter number := 0;  -- not 1 for the case of empty block
begin
  first_record;
  while :system.last_record = 'FALSE'
  loop
    counter := counter + 1;
    next_record;
  end loop;

  if counter > 0 then
     counter := counter + 1;  -- the last record was not counted
  end if;
  
  message('There are ' || to_char(counter) || ' records in the block');
end;
Re: Count rows of record inserted [message #154493 is a reply to message #154492] Mon, 09 January 2006 00:56 Go to previous messageGo to next message
juicyapple
Messages: 92
Registered: October 2005
Member
Thanks.
If I want to copy these inserted records to the fields in other data block, can you suggest me some useful ways? I don't have idea on how to do it.
Can use cursor to do it? But normally I use cursor to get data from table and not form...

Re: Count rows of record inserted [message #154497 is a reply to message #154493] Mon, 09 January 2006 01:25 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You would use the same principle as above - scroll through the block, read values in fields and insert them somewhere else.

However, if that is the common thing you are doing, perhaps you might want to consider use of global temporary tables and work with them, instead of using control block(s) in the form.
Re: Count rows of record inserted [message #154502 is a reply to message #154497] Mon, 09 January 2006 01:52 Go to previous message
juicyapple
Messages: 92
Registered: October 2005
Member
This is what I done but seem very confusing...

There is one row of record in blockA, when insert several new records in blockB, it will delete that record in blockA, replaced with records from blockB.
But sum of total in blockB cannot exceed blockA.
please give some suggestion...
-------------------------------------------------

declare
total number;
total2 number;
begin

go_block('blockB');
first_record;

go_block('blockA');
--total := :blockA.total;
delete_record; --delete the existing record in blockA to insert new record copy from blockB
create_record;
:blockA.material := :blockB.material;
:blockA.qty := :blockB.qty;
:blockA.total := :blockB.total;
--total2 := :blockB.total;

loop
go_block('blockB');
next_record;
exit when blockB.material is null;

go_block('blockA');
create_record;

:blockA.material := :blockB.material;
:blockA.qty := :blockB.qty;
:blockA.total := :blockB.total;
--total2 := total2 + :blockB.total;

end loop;



go_item('blockA.material');

end;
Previous Topic: Unable to read full image (.tif) file
Next Topic: Password help
Goto Forum:
  


Current Time: Fri Sep 20 02:28:59 CDT 2024