Copy Records From One Data Block To Another Data Block In Oracle Forms

In this tutorial you will learn to copy the records from one data block to another data block on same form and on a same canvas in Oracle Forms.

 

Below is the screen shot of the form and you can download this form for your reference from the following link (Table script is also included):

Download


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.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值