In the above picture you can see that there are two blocks, first one is the block based on a table and the second one is a non-database data block, but this is not necessary you can make the block based on a table also.
The functionality of this form is, user will select the record above then click on Copy button to copy the record below, it is like making the selection of records from a data block. User can also remove the records from the second block where the records are being copied.
The whole functionality is written on the push button Copy and below is the code written on When-Button-Pressed trigger:
BEGIN GO_BLOCK ('COPIED');
FIRST_RECORD; LOOP -- CHECK THE VALUE IF RECORD IS EMPTY IF NOT THEN JUMP TO ANOTHER IF :copied.empno IS NULL THEN -- EXIT TO COPY THE RECORD EXIT; END IF; -- ELSE CONTINUE FINDING EMPTY RECORD IF :SYSTEM.LAST_RECORD = 'TRUE' THEN CREATE_RECORD; EXIT; END IF; NEXT_RECORD; END LOOP; -- COPY THE RECORD :copied.empno := :scott_emp.empno; :copied.ename := :scott_emp.ename; :copied.job := :scott_emp.job; :copied.mgr := :scott_emp.mgr; :copied.hiredate := :scott_emp.hiredate; :copied.sal := :scott_emp.sal; :copied.comm := :scott_emp.comm; :copied.deptno := :scott_emp.deptno; -- GO BACK TO FIRST BLOCK GO_BLOCK ('SCOTT_EMP'); END;
You should replace the value of data block and item reference (:copied.empno := :scott_emp.empno) with your form's data block and items.
Below is the code of Remove push button of second data block to clear the record when pressed:
CLEAR_RECORD;
Just a One line code which is sufficient.