How To Commit Just One Data Block Changes In Oracle Forms

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.

时间: 2024-12-08 10:49:45

How To Commit Just One Data Block Changes In Oracle Forms的相关文章

Giving Data Backup Option in Oracle Forms 6i

Suppose you want to give the data backup option in Oracle Forms application to some client users, where you have installed Oracle 11g client or direct from server. The following procedure executes a batch file placed in current working directory of t

Writing Text File From A Tabular Block In Oracle Forms

The example given below for writing text file or CSV using Text_IO package from a tabular block in Oracle Forms. Suppose there is a tabular grid data block "Job_History" in your forms and you want to write a CSV on click of a button by reading w

Sort Detail Data Block Example - Oracle Forms

Example is given below to sort detail data block data (toggle asc or desc) with push buttons used as header of grid, by setting ORDER_BY property of data block using SET_BLOCK_PROPERTY command. The following is the screen shot of this example and thi

Create Data Block Based On From Clause Query In Oracle Forms

Example is given below to create a data block based on From Clause query in Oracle Forms. The following are the steps: Create a data block manually and set the following properties: You can specify different query as per your need. Then create the it

模拟ORA-26040: Data block was loaded using the NOLOGGING option

我们知道通过设置nologging选项.能够加快oracle的某些操作的运行速度,这在运行某些维护任务时是非常实用的,可是该选项也非常危急,假设使用不当,就可能导致数据库发生ORA-26040错误. 首先.构造使用环境. SQL> select tablespace_name,logging,force_logging from dba_tablespaces; TABLESPACE_NAME LOGGING FOR ------------------------------ --------

ORA-01578 data block corrupted 数据文件损坏 与 修复 (多为借鉴 linux)

好吧,先说说造成崩溃的原因: 使用redhat 5.9 Linux 作为数据库服务器, 周五数据库正在使用中,硬关机造成数据库文件部分损坏(周一上班时,应用程序启动不起来,查看日志文件时,发现一个数据表映射失败) 使用pl/sql 查询数据文件时,发现 查询表正常,但是使用 where限制条件的时候,会造成崩溃      (只是为了说明命令,未保留当时警告截图) 然后出现 ORA-01578 data block corrupted , 因此 问题排查为当前数据表索引存在问题, 因此使用备份数据

data block address

这里讨论的不是数据库管理员DBA,而是数据块地址DBA:Data Block Address! A Data Block Address (DBA) is the address of an Oracle data block for access purposes. ----源自<Oracle内核技术揭秘>的探索 DBA的结构:8以后,DBA中,前10个二进制位是文件号,后面的就是块号了. DBA的转换:dump出来文件之后,有的DBA后面有转换后的结果,比如: rdba: 0x010001

Oracle Form开发应用之Data Block级别的主要属性

项目(英文)  项目(中文) 说明 General 常规 * Name 名称  Data Block 名称 eg:BLK_NAME  * Subclass Information   子类信息  设定Property class eg:BLOCK Navigation 导航  * Navigation Style  导航器风格  当光标到记录的最后一个item后  Same Recorde: 返回到第一个Item  Change Recorde: 转到下一个Recorde的第一个Item  Ch

Data Block Compression

The database can use table compression to eliminate duplicate values in a data block. This section describes the format of data blocks that use compression. The format of a data block that uses basic and advanced row compression is essentially the sa