`
xiang37
  • 浏览: 426777 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Oracle Forms的四种提交方式

 
阅读更多

一共有四种提交方式:commit_form、Do_key('commit_form')、commit、FORMS_DDL('commit');

 

 

方式一:commit_form

 

先验证forms代码的数据,然后对每个数据块提交。

COMMIT_FORM Built-in 

 

Description

 

 

Causes Oracle Forms to update data in the database to match data in the form. Oracle Forms first validates the form, then, for each block in the form, deletes, inserts, and updates to the database, and performs a database commit. As a result of the database commit, the database releases all row and table locks. 

 

If the end user has posted data to the database during the current Runform session, a call to the COMMIT_FORM Built-in commits this data to the database. 

 

Following a commit operation, Oracle Forms treats all records in all base-table blocks as if they are queried records from the database. Oracle Forms does not recognize changes that occur in triggers that fire during commit processing. 

Syntax

 

 

PROCEDURE COMMIT_FORM; 

 

 

 

Built-in Type restricted procedure 

 

Enter Query Mode no 

COMMIT_FORM Restrictions 

 

 

If you use a PL/SQL COMMIT statement in an anonymous block or a form-level procedure, Oracle Forms interprets that statement as a call to the COMMIT_FORM Built-in. 

COMMIT_FORM Examples 

Example 1

 

 /*

 

** Built-in: COMMIT_FORM 

** Example: If there are records in the form to be 

** committed, then do so. Raise an error if the 

** commit was not successful. 

*/ 

BEGIN 

/* 

** Force validation to happen first 

*/ 

Enter; 

IF NOT Form_Success THEN 

RAISE Form_Trigger_Failure; 

END IF; 

/* 

** Commit if anything is changed 

*/ 

IF :System.Form_Status = 'CHANGED' THEN 

Commit_Form; 

/* 

** A successful commit operation sets Form_Status back 

** to 'QUERY'. 

*/ 

IF :System.Form_Status <> 'QUERY' THEN 

Message('An error prevented your changes from being 

committed.'); 

Bell; 

RAISE Form_Trigger_Failure; 

END IF; 

END IF; 

END; 

 

Example 2

 

 /*

 

** Built-in: COMMIT_FORM 

** Example: Perform Oracle Forms database commit during commit 

** processing. Decide whether to use this Built-in 

** or a user exit based on a global flag setup at 

** startup by the form, perhaps based on a 

** 

** Trigger: On-Commit 

*/ 

BEGIN 

/* 

** Check the global flag we set during form startup 

*/ 

IF :Global.Using_Transactional_Triggers = 'TRUE' THEN 

User_Exit('my_commit'); 

/* 

** Otherwise, do the right thing. 

*/ 

ELSE 

Commit_Form; 

END IF;

 

 

 

方式二:Do_key

 

 

 

DO_KEY Built-in

 

Description

 

先执行触发器的内容,如果没有则子程序执行。

Executes the key trigger that corresponds to the specified Built-in subprogram. If no such key trigger exists, then the specified subprogram executes. This behavior is analogous to pressing the corresponding function key. 

Syntax

 

 

PROCEDURE DO_KEY

(built_in_subprogram_name VARCHAR2); 

 

Built-in Type restricted procedure 

 

Enter Query Mode yes 

Parameters

 

built_in_subprogram_name 

 

    Specifies the name of a valid Built-in subprogram. 

 

Built-in  

 

Key Trigger  

 

Associated Function Key  

 

 

CLEAR_BLOCK  Key-CLRBLK  [Clear Block]  

 

 

CLEAR_FORM  Key-CLRFRM  [Clear Form]  

 

 

CLEAR_RECORD  Key-CLRREC  [Clear Record]  

 

 

COMMIT_FORM  Key-COMMIT  [Commit] 

 

COUNT_QUERY  Key-CQUERY  [Count Query Hits] 

 

 

CREATE_RECORD  Key-CREREC  [Insert Record]  

 

 

DELETE_RECORD  Key-DELREC  [Delete Record]  

 

 

DOWN  Key-DOWN  [Down]  

 

 

DUPLICATE_ITEM  Key-DUP-ITEM  [Duplicate Item]  

 

 

DUPLICATE_RECORD  Key-DUPREC  [Duplicate Record]  

 

 

EDIT_TEXTITEM  Key-EDIT  [Edit]  

 

 

ENTER  Key-ENTER  [Enter] 

 

 

ENTER_QUERY  Key-ENTQRY  [Enter Query]  

 

 

EXECUTE_QUERY  Key-EXEQRY  [Execute Query]  

 

 

EXIT_FORM  Key-EXIT  [Exit/Cancel]  

 

 

HELP  Key-HELP  [Help]  

 

 

LIST_VALUES  Key-LISTVAL  [List]  

 

 

LOCK_RECORD  Key-UPDREC  [Lock Record]  

 

 

NEXT_BLOCK  Key-NXTBLK  [Next Block] 

 

 

NEXT_ITEM  Key-NEXT-ITEM  [Next Item]  

 

 

NEXT_KEY  Key-NXTKEY  [Next Primary Key Fld]  

 

 

NEXT_RECORD  Key-NXTREC  [Next Record]  

 

 

NEXT_SET  Key-NXTSET  [Next Set of Records]  

 

 

PREVIOUS_BLOCK  Key-PRVBLK  [Previous Block]  

 

 

PREVIOUS_ITEM  Key-PREV-ITEM  [Previous Item]  

 

 

PREVIOUS_RECORD  Key-PRVREC  [Previous Record] 

 

 

PRINT  Key-PRINT  [Print]  

 

 

SCROLL_DOWN  Key-SCRDOWN  [Scroll Down]  

 

 

SCROLL_UP  Key-SCRUP  [Scroll Up]  

 

 

UP  Key-UP  [Up]  

 

DO_KEY Restrictions 

DO_KEY accepts Built-in names only, not key names: DO_KEY(ENTER_QUERY). 

 

To accept a specific key name, use the EXECUTE_TRIGGER Built-in: EXECUTE_TRIGGER('KEY_F11'). 

DO_KEY Example

 

/*

 

** Built-in: DO_KEY 

** Example: Simulate pressing the [Execute Query] key. 

*/ 

BEGIN 

   DO_KEY('Execute_Query'); 

END; 


方式三:commit
提交数据库block以及forms里面的insert,update,delete等dll语句;如果有冲突以界面上的block为主。


方式四:FORMS_DDL(commit)

仅仅对forms内部程序提交,不会对block进行操作。

FORMS_DDL Built-in
 
Description
 

Issues dynamic SQL statements at runtime, including server-side PL/SQL and DDL. 



Note: All DDL operations issue an implicit COMMIT and will end the current transaction without allowing Oracle Forms to process any pending changes
Syntax
 

FUNCTION FORMS_DDL
(statement VARCHAR2); 

Built-in Type unrestricted function 

Enter Query Mode yes 
Parameters
 

statement Any string expression up to 32K: a literal an expression or a variable representing the text of a block of dynamically created PL/SQL code a DML statement or a DDL statement 
Usage Notes
 

Commit (or roll back) all pending changes before you issue the FORMS_DDL command. All DDL operations issue an implicit COMMIT and will end the current transaction without allowing Oracle Forms to process any pending changes, as well as losing any locks Oracle Forms may have acquired. 

Some supplied stored procedures issue COMMIT or ROLLBACK commands as part of their logic. Make sure all pending changes in the form are committed or rolled back before you call those Built-ins. Use the SYSTEM.FORM_STATUS variable to check whether there are pending changes in the current form before you issue the FORMS_DDL command. (See Example 4.) 

If you use FORMS_DDL to execute a valid PL/SQL block: Use semicolons where appropriate. Enclose the PL/SQL block in a valid BEGIN/END block structure. Do not end the PL/SQL block with a slash. Line breaks, while permitted, are not required. 

If you use FORMS_DDL to execute a single DDL statement: Omit the trailing semicolon to avoid an invalid character error. 

To check whether the statement issued using FORMS_DDL executed correctly, use the FORM_SUCCESS or FORM_FAILURE Boolean functions. If the statement did not execute correctly, check the error code and error text using DBMS_ERROR_CODE and DBMS_ERROR_TEXT. Note that the values of DBMS_ERROR_CODE and DBMS_ERROR_TEXT are not automatically reset following successful execution, so their values should only be examined after an error has been detected by a call to FORM_SUCCESS or FORM_FAILURE. 
FORMS_DDL Restrictions 


The statement you pass to FORMS_DDL may not contain bind variable references in the string, but the values of bind variables can be concatenated into the string before passing the result to FORMS_DDL. For example, this statement is not valid: 

Forms_DDL ('Begin Update_Employee (:emp.empno); End;'); 

However, this statement is valid, and would have the desired effect: 

Forms_DDL ('Begin Update_Employee ('||TO_CHAR(:emp.empno) 
||');End;'); 

However, you could also call a stored procedure directly, using Oracle's shared SQL area over multiple executions with different values for emp.empno: 

Update_Employee (:emp.empno); 

SQL statements and PL/SQL blocks executed using FORMS_DDL cannot return results to Oracle Forms directly. (See Example 4.) 

In addition, some DDL operations cannot be performed using FORMS_DDL, such as dropping a table or database link, if Oracle Forms is holding a cursor open against the object being operated upon. 
FORMS_DDL Examples 


Example 1

/*

** Built-in: FORMS_DDL 
** Example: The expression can be a string literal. 
*/ 
BEGIN 
Forms_DDL('create table temp(n NUMBER)'); 
IF NOT Form_Success THEN 
Message ('Table Creation Failed'); 
ELSE 
Message ('Table Created'); 
END IF; 
END; 

Example 2

/*

** Built-in: FORMS_DDL 
** Example: The string can be an expression or variable. 
** Create a table with n Number columns. 
** TEMP(COL1, COL2, ..., COLn). 
*/ 
PROCEDURE Create_N_Column_Number_Table (n NUMBER) IS 
my_stmt VARCHAR2(2000); 
BEGIN 
my_stmt := 'create table tmp(COL1 NUMBER'; 
FOR I in 2..N LOOP 
my_stmt := my_stmt||',COL'||TO_CHAR(i)||' NUMBER'; 
END LOOP; 
my_stmt := my_stmt||')'; 
/* 
** Now, create the table... 
*/ 
Forms_DDL(my_stmt); 
IF NOT Form_Success THEN 
Message ('Table Creation Failed'); 
ELSE 
Message ('Table Created'); 
END IF; 
END; 

Example 3: 

/*

** Built-in: FORMS_DDL
** Example: The statement parameter can be a block 
** of dynamically created PL/SQL code. 
*/ 
DECLARE 
procname VARCHAR2(30); 
BEGIN 
IF :global.flag = 'TRUE' THEN 
procname := 'Assign_New_Employer'; 
ELSE 
procname := 'Update_New_Employer'; 
END IF; 
Forms_DDL('Begin '|| procname ||'; End;'); 
IF NOT Form_Success THEN 
Message ('Employee Maintenance Failed'); 
ELSE 
Message ('Employee Maintenance Successful'); 
END IF; 
END; 

Example 4:

/*

** Built-in: FORMS_DDL
** Example: Issue the SQL statement passed in as an argument, 
** and return a number representing the outcome of 
** executing the SQL statement. 
** A result of zero represents success. 
*/ 
FUNCTION Do_Sql (stmt VARCHAR2, check_for_locks BOOLEAN := TRUE) 
RETURN NUMBER 
IS 
SQL_SUCCESS CONSTANT NUMBER := 0; 
BEGIN 
IF stmt IS NULL THEN 
Message ('DO_SQL: Passed a null statement.'); 
RETURN SQL_SUCCESS; 
END IF; 
IF Check_For_Locks AND :System.Form_Status = 'CHANGED' THEN 
Message ('DO_SQL: Form has outstanding locks pending.'); 
RETURN SQL_SUCCESS; 
END IF; 
Forms_DDL(stmt); 
IF Form_Success THEN 
RETURN SQL_SUCCESS; 
ELSE 
RETURN Dbms_Error_Code; 
END IF; 
END; 
分享到:
评论

相关推荐

    Oracle Forms开发常用技巧

    Oracle Forms是一种用于构建企业级应用的开发工具,尤其在Oracle E-Business Suite (EBS) 中广泛使用。本文将深入探讨Oracle Forms开发中的常用技巧,主要涉及如何手动提交Request以及FND_REQUEST.SUBMIT_REQUEST...

    Oracle Forms Builder开发文档

    Oracle Forms 是一种基于客户端-服务器架构的开发平台,它允许开发者使用图形化界面设计复杂的业务表单和流程。在12.2版本的开发者指南中,包含了丰富的信息和技术细节,帮助开发者深入理解和利用这一强大的工具。 ...

    OracleForms基础

    OracleForms 是一种用于开发企业级应用的工具,尤其在ORACLE EBS(Oracle Enterprise Business Suite)环境中广泛应用。它是Oracle Database的一部分,提供了丰富的图形界面来构建交互式的业务应用程序。以下是...

    Oracle Forms&Reports开发

    在本文中,我们将深入探讨如何使用Oracle Forms Builder进行开发,并特别关注如何手动提交Request以及FND_REQUEST.SUBMIT_REQUEST函数的使用。 在Oracle Forms环境中,提交Request是与Oracle Request Manager交互的...

    oracle forms 触发器执行顺序

    ### Oracle EBS Forms 触发器执行顺序详解 Oracle E-Business Suite (EBS) 是一个集成的企业资源规划 (ERP) 解决方案,它利用了 Oracle 的技术来提供全面的业务流程管理。其中,Oracle Forms 是一个强大的工具,...

    OFormsCI:Oracle Forms / Reports融合中间件的持续集成-开源

    OFormsCI 为Oracle Forms 和 Reports 开发者提供了一种高效且可靠的持续集成解决方案。通过与Git、Jenkins和WebLogic Server的紧密集成,它极大地简化了开发、测试和部署流程,提升了整体项目管理的效率。作为开源...

    Oracle Form 触发器的执行顺序

    (5)POST-FORMS-COMMIT:在 FORM 提交后执行的触发器。 (6)PRE-BLOCK:在 BLOCK 级别上执行的触发器。 (7)KEY-COMMIT:在提交记录时执行的触发器。 (8)WHEN-NEW-ITEM-INSTANCE:在项实例创建时执行的触发器。...

    TEST-EMP-IMAGE.rar_oracle

    首先,Oracle Forms是一种用于构建企业级应用的工具,它允许开发者创建与数据库交互的图形用户界面。在这个场景中,我们关注的是如何处理图像数据,这通常涉及到BLOB(Binary Large Object)数据类型,它是Oracle...

    winform终端连接oracle数据库及SQL数据库

    在IT行业中,Windows Forms(WinForms)是一种常用的开发桌面应用程序的框架,它是.NET Framework的一部分,由微软提供。本文将深入探讨如何使用C#语言在WinForm应用中建立与Oracle及SQL Server数据库的连接,以及...

    oracle ebs开发文档

    这部分内容主要介绍了如何在 Oracle Forms 中进行各种设置,比如: - **设置ITEM为必填项**:这可以通过 Forms 的属性设置来实现,确保用户必须填写某些字段才能提交数据。 - **设置ITEM的初始值为当前日期**:通过 ...

    总结java程序中操作Oracle数据库的常用操作1

    8. 事务管理:在Java中,可以使用`Connection`对象的`setAutoCommit(false)`关闭自动提交,然后通过`commit()`和`rollback()`手动控制事务的提交和回滚。 9. 关闭资源:在完成数据库操作后,必须关闭`ResultSet`,`...

    ORACLEFORM培训资料.docx

    - Oracle Forms 是一种应用程序开发工具,主要用于构建与Oracle数据库交互的界面。 - 它提供了一种方法来创建表格形式的界面,用于查询、插入、更新和删除数据库中的数据。 - **Form模块的结构** - 形式上,Form...

    Oracle erp个人学习笔记

    在Oracle ERP的学习与实践过程中,系统配置是基础且关键的环节,尤其是在部署和运行Oracle Forms 6i时。配置正确与否直接影响到系统的稳定性和功能的实现。其中,对`TNSNAMES.ORA`文件的修改是连接数据库必不可少的...

    Oracle Form 6.0 Triger

    Oracle Forms 是一种用于构建企业级应用程序的强大工具,它最初由Oracle公司开发并随Oracle数据库一起发布。Oracle Forms 6.0是该系列中的一个版本,在90年代末至2000年初广泛应用于基于表单的应用程序开发中。它...

    Oracle Form中COMMIT的概述及使用技巧

    - `QUIETCOMMIT` 是Oracle Forms中一种无声的提交方式,它不会显示任何确认消息。在调用`app_form.quietcommit`函数时,如果没有任何修改,通常会出现提示信息,但通过`QUIETCOMMIT`,这些提示会被抑制。此函数返回...

    Oracle Form觸發器、系統變量精解2

    触发器是Oracle Forms中的一种特殊事件处理机制,用于响应特定的操作或事件。它们可以被用来执行一系列复杂的逻辑操作,如数据验证、计算和用户界面控制等。触发器使得开发者能够更加灵活地控制应用程序的行为,并且...

    Oracle认证介绍与练习题

    - 当使用`SELECT FOR UPDATE`语句锁定行时,必须通过提交(COMMIT)或回滚(ROLLBACK)事务来解锁。 5. **删除列问题:** - **答案:A.ALTERTABLE STATE DROP COLUMN UPDATE_DT;** - 删除表中的列需要使用`ALTER ...

    ORACLEEBS_FORM

    **Oracle EBS(Enterprise Business Suite)Form** 是一种基于Oracle Forms技术构建的企业级应用程序开发工具,广泛应用于Oracle EBS系统的定制化开发。它不仅能够帮助开发者高效地构建用户界面,还能与Oracle EBS的...

Global site tag (gtag.js) - Google Analytics