I have a form with a multi-row block based on a table. The requirement is that the user can only enter 1 row into the block at a time and commit it. They should not be allowed to create a second row before committing the first.
I tried using a WHEN-CREATE-RECORD trigger like this:
if :system.block_status = 'CHANGED' then alert('Can only create one record at a time'); end if;
However, this prevents me creating a new record even after committing changes.
One way would be to loop through all records and if the second record isn't null, alert the user.
DECLARE n_index NUMBER := 0; BEGIN Go_block('block_name'); first_record; WHILE :SYSTEM.last_record != 'TRUE' LOOP next_record; IF :block_name.item_name IS NOT NULL THEN --replace item_name with one which the user will enter all the time n_index := n_index + 1; END IF; IF n_index > 0 THEN Alert('Only one record can be created at a time!'); END IF; END LOOP; END;