The following example finds the commission plan in the COMMPLAN table, based on the current value of the commcode item in the EMPLOYEE block in the form, to verify that the code is valid.
If the code in the COMMPLAN table is located, the description of the COMMPLAN is obtained and deposited in the non-database Description item. Otherwise, an error is raised.

/*
** Method 1: Using a SELECT...INTO statement, the trigger
** looks more readable but can be less efficient
** than Method 2 because for ANSI Standard
** compliance, the SELECT...INTO statement must
** return an error if more than one row is
** retrieved that matches the criteria. This
** implies PL/SQL may attempt to fetch data twice
** from the table in question to insure that there
** aren’t two matching rows.
*/

BEGIN
SELECT description
INTO :Employee.Commplan_Desc
FROM commplan
WHERE commcode = :Employee.Commcode;
EXCEPTION
WHEN No.Data_Found THEN
Message(’Invalid Commission Plan, Use <List> for help’);
RAISE Form_trigger_Failure;
WHEN Too_Many_Rows THEN
Message(’Error. Duplicate entries in COMMPLAN table!’);
RAISE Form_trigger_Failure;
END;

/*
** Method 2: Using an Explicit Cursor looks a bit more
** daunting but is actually quite simple. The
** SELECT statement is declared as a named cursor
** in the DECLARE section and then is OPENed,
** FETCHed, and CLOSEd in the code explicitly
** (hence the name). Here we guarantee that only a
** single FETCH will be performed against the
** database.
*/

DECLARE
noneFound BOOLEAN;
CURSOR cp IS SELECT description
FROM commplan
WHERE commcode = :Employee.Commcode;
BEGIN
OPEN cp;
FETCH cp INTO :Employee.Commplan_Desc;
noneFound := cp%NOTFOUND;
CLOSE cp;
IF noneFound THEN
Message(’Invalid Commission Plan, Use <List> for help’);
RAISE Form_trigger_Failure;
END IF;
END;

最新文章

  1. Delphi 各版本新特性功能网址收集
  2. [译]SQL Server 之 查询计划缓存和重编译
  3. 2014多校第六场 1005 || HDU 4925 Apple Tree
  4. UVA 10006 - Carmichael Numbers 数论(快速幂取模 + 筛法求素数)
  5. 使用air进行移动app开发常见功能和问题(一)
  6. HTML 5 全局属性
  7. logstash Codec
  8. WCF消息交换模式之双工通讯(Duplex)
  9. CreateMutex()参数报错问题
  10. SqlServer拆分列
  11. Mysql清理二进制日志的技巧
  12. 21 viewPager--- hzScrollView ----llContainer
  13. Linux进程实践(2) --僵尸进程与文件共享
  14. 为View设置左右切换动画
  15. 软件工程实践-WC项目之C实现
  16. git上传新项目到coding
  17. JAVA实训第二次作业
  18. 快速导入导出Oracle数据demo(sqlldr、UTL_FILE)
  19. SQL Server 跨服务器查询
  20. javascript的数组之find()

热门文章

  1. YZM的全排列
  2. VMWare联网
  3. SQL Server 数据库中关于死锁的分析
  4. javascript 金额格式化
  5. ORACLE添加表约束的语法示例
  6. HDU 2665 &amp;&amp; POJ 2104(主席树)
  7. symfony中twig的模板载入
  8. Linux hrtimer分析(2)
  9. linux新内核的时钟机制代码
  10. maven 手动安装jar到仓库的命令