You have an Oracle Form in which you have multiple data blocks and requirement is to commit just one data block changes and not to effect any other data blocks. But suppose you have a commit_form button also in form which will commit all the data block changes and that functionality is ok and it should be there. But for a specific block there is a requirement to commit only that block changes when edited.

If you got this kind of requirement then you can insert and update records from that data block to database externally, I mean using insert and update statements and not by Oracle form's default commit behavior.

To accomplish this task you need to give a push button to the user to save explicitly that data block changes. I have created a form for this example and below is the screen shot of this form:

You can download this form with the following button: Download

As you can see in above picture, there are two blocks, first one is Department and the second one is Employees and there is a push button labeled Commit Employees. In this form if user will change the data in both data blocks and presses the Commit Employees button then it will save only the Employees data block changes.

Following is the code is written in Commit Employees button to perform this task:

DECLARE
   CURSOR c_emp (p_emp emp.empno%TYPE)
   IS
      SELECT 'Y'
        FROM emp
       WHERE emp.empno = p_emp;

   v_exists   VARCHAR2 (1);
BEGIN
   GO_BLOCK ('Emp');
   FIRST_RECORD;

   LOOP
      IF :SYSTEM.record_status = 'CHANGED'
         OR:SYSTEM.record_status = 'INSERT'
      THEN
         OPEN c_emp (:emp.empno);

         FETCH c_emp INTO v_exists;

         CLOSE c_emp;

         IF NVL (v_exists, 'N') = 'Y'
         THEN
            UPDATE emp
               SET ename = :emp.ename,
                   job = :emp.job,
                   mgr = :emp.mgr,
                   hiredate = :emp.hiredate,
                   sal = :emp.sal,
                   comm = :emp.comm,
                   deptno = :emp.deptno
             WHERE empno = :emp.empno;
         ELSE
            INSERT INTO emp (empno,
                             ename,
                             job,
                             mgr,
                             hiredate,
                             sal,
                             comm,
                             deptno)
                VALUES (:emp.empno,
                        :emp.ename,
                        :emp.job,
                        :emp.mgr,
                        :emp.hiredate,
                        :emp.sal,
                        :emp.comm,
                        :emp.deptno);
         END IF;
      END IF;

      IF :SYSTEM.LAST_RECORD = 'TRUE'
      THEN
         EXIT;
      END IF;

      NEXT_RECORD;
   END LOOP;

   FORMS_DDL ('commit');
   -- REQUERY TO REFRESH CHANGES
   CLEAR_BLOCK (no_validate);
   GO_BLOCK ('dept');
   CLEAR_BLOCK (no_validate);
   EXECUTE_QUERY;
EXCEPTION
   WHEN OTHERS
   THEN
      FORMS_DDL ('rollback');
      MESSAGE ('error occurred.');
END;

What this above code will do is, it will check if record status is changed or new and then it will check from database that the record exists or not and if exists then it will update else will insert a new record.

最新文章

  1. NuGet学习笔记3——搭建属于自己的NuGet服务器
  2. mysql设置连接超时时间参数:wait_timeout
  3. ASP.NET中身份验证
  4. Visual Assist的破解与安装
  5. URL参数加密解密
  6. arm str 指令
  7. 求高手帮忙解决一下问题Java Web Cookie实例
  8. centos手动配置IP和DNS
  9. Filecoin:募资详情和Token分发详情
  10. Golang学习---常用库
  11. 什么是SQL
  12. 《JavaScript-The Definitive Guide》读书笔记:函数定义和函数调用
  13. 【30集iCore3_ADP出厂源代码(ARM部分)讲解视频】30-8底层驱动之RTC
  14. shell 多重条件判断
  15. python 单变量线性回归
  16. Vue 动态组件、动画、插件
  17. Unexpected token o in JSON at position 1 at JSON.parse (<anonymous>) SyntaxError: Unexpected token R in JSON at position 0 at JSON.parse (<anonymous>)
  18. Oracle 角色、权限
  19. BZOJ 3594 [Scoi2014]方伯伯的玉米田(二维树状数组)
  20. mysql获取插入的id主键

热门文章

  1. [oldboy-django][2深入django]django模板使用函数
  2. POJ 2376:Cleaning Shifts(贪心)
  3. BZOJ 3462 DZY Loves Math II ——动态规划 组合数
  4. http2新特性
  5. 【14】redux 之 redux-actions
  6. 2017最好的JavaScript框架、库和工具 — SitePoint
  7. bzoj 2749 - 外星人
  8. Java语法糖(二)
  9. 51Nod 1003 1004 1009
  10. HDU 4388 Stone Game II {博弈||找规律}