0
votes

I'm working with Oracle Forms Builder, and I've a block with several records. The code looks somewhat like this

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; 

Right before the next_record, inside the ELSE segment, I need to remove the current record and re-insert it. The problem isn't removing the record, it's re-inserting it. Any ideas? Thanks in advance.

2
Why do you want to do this peculiar thing rather just doing an update? - APC
I'm not sure if the update will update the dependent fields... But if updates does, then, do tell me how to do the update :P - Nacho321

2 Answers

2
votes

I agree with APC, instead of re-inserting the record which means deleting and then inserting it again, a simpler approach would be to just update the fields in the DB (or non-DB) Block. Something like-

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;
0
votes

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;