If Value Exists Then Query Else Allow Create New in Oracle Forms An Example
Posted ORACLE EBS
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了If Value Exists Then Query Else Allow Create New in Oracle Forms An Example相关的知识,希望对你有一定的参考价值。
An example given below for Oracle Forms, when a value exists then execute query for that value to display the correspondent record else allow user to create a new record for that value.
The following is the example given for HR schema employee table, in this example user will enter an empoyee id and if the employee id exists it will query the record else allow user to create a new record, the trigger written on key-next-item trigger, you can download the employees.fmb form also from the following link employees.fmb
KEY-NEXT-ITEM trigger code
declare
v_empid employees.employee_id%type;
Begin
Select employee_id into v_empid
from hr.employees
where employee_id = :employees.employee_id;
-- value exists
-- set block property and execute query
clear_block(no_validate);
set_block_property(\'employees\', default_where, \'employee_id = \'||v_empid);
execute_query;
set_block_property(\'employees\', default_where, \'\');
next_item;
exception
when no_data_found then
-- when not then clear block and allow to add new
v_empid := :employees.employee_id;
clear_block(no_validate);
:employees.employee_id := v_empid;
next_item;
End;
v_empid employees.employee_id%type;
Begin
Select employee_id into v_empid
from hr.employees
where employee_id = :employees.employee_id;
-- value exists
-- set block property and execute query
clear_block(no_validate);
set_block_property(\'employees\', default_where, \'employee_id = \'||v_empid);
execute_query;
set_block_property(\'employees\', default_where, \'\');
next_item;
exception
when no_data_found then
-- when not then clear block and allow to add new
v_empid := :employees.employee_id;
clear_block(no_validate);
:employees.employee_id := v_empid;
next_item;
End;
以上是关于If Value Exists Then Query Else Allow Create New in Oracle Forms An Example的主要内容,如果未能解决你的问题,请参考以下文章
oracle 菜鸟学习之 decode中if-then-else逻辑
ruby 来自https://stackoverflow.com/questions/4817266/if-string-is-empty-then-return-some-default-value