Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

POPULATING A DATABLOCK PROBLEM

Status
Not open for further replies.

thebull1

Programmer
Oct 24, 2001
68
I have a non-displaying datablock that is being populated using the following cursor:-

for readingrec in reading loop
:db_gross_next.rtime := readingrec.rtime;
:db_gross_next.meter_read := readingrec.meter_read;
ll_curr_gross := Get_Block_property('db_gross_next',current_record);
next_record;
end loop;

My problems are:-
1. The count ll_curr_gross remains as 1(One) throughout even when the cursor loops many times...

2. Consequently, I have some code on the post_change of :db_gross_next.meter_read that is not executed at all, which I xpected at next_record of every loop run..

Please help...
 
I dont understand the 'non displaying data block' part. The cursor cannot visit a block that has no displayed items and you would (normally) get an error if you tried to navigate to it.

However, if the block is displayed somewhere you need to make sure 'insert allowed' property is enabled on the block. This should allow you to add a record then navigate down with next_record. You also need to make sure the cursor is actually in the block to begin with (see above) with a GO_BLOCK before the LOOP.

:SYSTEM.CURSOR_RECORD is the same as get_block_property('block',current_record), but is only applicable to the current block.
 
Thanks Lewisp...
With "non-displayed" I mean that the user does not see the lock. I'mm pupulating it in the "background". Do I still need to have it on a canvas for it to be pupulated as often as the cursor loops. Currently, only the first record is populated, and with the next looping, it is overwritten. How do I ensure that my next_record actually does that. My 'insert allowed' is OK.
 
next_record works only for current block, so you have to issue go_block before. If you have no navigable items, this operation fails, so if not processed your next_record will be executed (and possibly faile!) on the previous block. If your block is not displayed at all I would recommend you to use some kind of array instead of block: recordgroup or pl/sql table.
With storing data in block you will also depend on clear_form, that may destroy your data.
 
try to do like this:

for readingrec in reading loop

go_block( 'db_gross_next' );

if get_record_property( :system.trigger_record, :system.cursor_block ) in ( 'QUERY', 'CHANGED' ) then
insert_record;
end if;

:db_gross_next.rtime := readingrec.rtime;
:db_gross_next.meter_read := readingrec.meter_read;

next_record;

end loop;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top