为了帮助可能面临类似问题的其他人,我想发布我的解决方案。
我松散地将我的实现基于我在研究期间发现的this tutorial。
我在 WHEN_NEW_FORM_INSTANCE 触发器中创建了一个 RecordGroup 并添加了我需要存储的所有列:
declare
rg_name varchar2(40) := 'SELECTED';
rg_id recordgroup;
gc_id groupcolumn;
begin
/* Make sure the record group does not already exist. */
rg_id := find_group(rg_name);
/* If it does not exist, create it and add the
** necessary columns to it. */
if id_null(rg_id) then
rg_id := create_group(rg_name);
/* Add columns to the record group */
gc_id := add_group_column(rg_id, 'Barcode', number_column);
gc_id := add_group_column(..);
end if;
然后我更改了我的 WHEN_CHECKBOX_CHANGED 以根据复选框的值在 RecordGroup 中添加或删除行。
declare
row_no number;
rg_id recordgroup := find_group('SELECTED');
gc_id groupcolumn;
total_rows number;
barcode number;
begin
total_rows := get_group_row_count(rg_id);
if :block.checkbox = 1 then
/* Add selected row to the RecordGroup */
add_group_row(rg_id, end_of_group);
set_group_number_cell('SELECTED.BARCODE',
total_rows + 1,
:block.number_item);
else
/* Find selected row in RecordGroup and remove it */
for i in 1 .. total_rows loop
barcode := get_group_number_cell('SELECTED.BARCODE', i);
if :block.number_item = barcode then
row_no := i;
exit;
end if;
end loop;
delete_group_row('SELECTED', row_no);
end if;
end;
在我的 WHEN_BUTTON_PRESSED 触发器中,它仅循环通过存储在 RecordGroup 中的选定行
declare
selected number;
row_no number;
begin
..
selected := get_group_row_count('SELECTED');
for j in 1 .. selected loop
begin
barcode := get_group_number_cell('SELECTED.BARCODE', j);
..
insert into (..);
commit;
exception
when others then
error_logging(..);
end;
end if;
delete_group_row('SELECTED', all_rows);
..
end;