0

我正在使用 Oracle Forms Builder,并且我有一个包含多条记录的块。代码看起来有点像这样

first_record;
IF NAME_IN('SYSTEM.LAST_RECORD') != 'TRUE' THEN                                 
  LOOP                  
    IF name_in('QOTLNDET_LINES.SERIAL_NUMBER') IS NOT NULL THEN                         
      QOTLNDET_LINES_REMOVE.Delete_Row;
      clear_record;     
    ELSE                    
      next_record;
    END IF;
    EXIT WHEN NAME_IN('SYSTEM.LAST_RECORD') = 'TRUE';

  END LOOP;
  execute_query;
  COMMIT;
  go_block('QOTHDDET_MAIN');
END IF; 

就在 next_record 之前,在 ELSE 段内,我需要删除当前记录并重新插入它。问题不是删除记录,而是重新插入它。有任何想法吗?提前致谢。

4

2 回答 2

2

我同意 APC,而不是重新插入记录,这意味着删除然后再次插入,更简单的方法是只更新 DB(或非 DB)块中的字段。就像是-

Go_Block('Block_B1');
Last_Record;
L_num_records := :system.cursor_record;
FOR i in 1..L_num_records
LOOP    
     Go_Block('Block_B1');
     Go_Record(i);
     --update the fields in the row
     :Block_B1.item1 := 'Set your value';
     :Block_B1.item2 := 'Set your value';
     ...
     ...
     Next_Record;
END LOOP;
First_Record;
于 2012-10-18T19:17:32.313 回答
0

I agree with APC and Annjawn that the update seems to be the correct way to go. When looking in your code it seems like you have your code in a pll library. This when you are using the name_in() instead of directly referencing the item. If this is true then means that you naturally can't use the direct reference when assigning the value to the item. Instead you have to use the copy(). It's some time since I have used name_in() and copy() but something like this should work:

IF NAME_IN('SYSTEM.LAST_RECORD') != 'TRUE' THEN                                 
  LOOP                  
    IF name_in('QOTLNDET_LINES.SERIAL_NUMBER') IS NOT NULL THEN                         
      QOTLNDET_LINES_REMOVE.Delete_Row;
      clear_record;     
    ELSE        
      Copy('new value', 'QOTLNDET_LINES.INVENTORY_ITEM');

      next_record;
    END IF;
    EXIT WHEN NAME_IN('SYSTEM.LAST_RECORD') = 'TRUE';

  END LOOP;
  execute_query;
  COMMIT;
  go_block('QOTHDDET_MAIN');
END IF; 
于 2012-10-19T08:02:12.467 回答