Oracle Forms is having its default records filter, which we can use through Enter Query mode to specify some search criteria or to filter records before display, but you can also create your own filter, which can be more user friendly and easy to use.
 
In this example I have created a form based on SCOTT's Emp table, below is the screen shot of this form and I am sharing also the form source code FMB file with Scott.Emp table script which can be downloaded with the following link Prequery_Filter.Zip 
 
 
Created two drop downs and one text item to specify search criteria and populating these drop downs on When-New-Form-Instance trigger, the following is the code written in it:
 
DECLARE
   rg_name   VARCHAR2 (40) := 'DYNGRP';
   rg_id     RecordGroup;
   errcode   NUMBER;
BEGIN
   /*
   ** Make sure group doesn't already exist
   */
   rg_id := FIND_GROUP (rg_name);
 
   /*
   ** If it exists then delete it first then re-create it.
   */
   IF NOT ID_NULL (rg_id)
   THEN
      DELETE_GROUP (rg_id);
   END IF;
 
   rg_id :=
      CREATE_GROUP_FROM_QUERY (
         rg_name,
         'select DISTINCT job, job job1 from scott_emp order by 1');
   /*
   ** Populate the record group
   */
   errcode := POPULATE_GROUP (rg_id);
   CLEAR_LIST ('FLTJOB');
   POPULATE_LIST ('FLTJOB', 'DYNGRP');
   ------- populate for department
   rg_id := FIND_GROUP (rg_name);
 
   /*
   ** If it exists then delete it first then re-create it.
   */
   IF NOT ID_NULL (rg_id)
   THEN
      DELETE_GROUP (rg_id);
   END IF;
 
   rg_id :=
      CREATE_GROUP_FROM_QUERY (
         rg_name,
         'select DISTINCT TO_CHAR(deptno), TO_CHAR(deptno) deptno1 from scott_emp order by 1');
   /*
   ** Populate the record group
   */
   errcode := POPULATE_GROUP (rg_id);
   CLEAR_LIST ('FLTDEPT');
   POPULATE_LIST ('FLTDEPT', 'DYNGRP');
   GO_BLOCK ('SCOTT_EMP');
   EXECUTE_QUERY;
END;
 
Then written the Pre-Query on Scott_Emp block to modify the "Where Clause" of that block at run time and following is the code:
 
DECLARE
VWHERE varchar2(1000) := 'empno is not null ';
begin
-- build where clause
if :fltjob is not null then
 vwhere := vwhere || 'and job = :fltjob ';
end if;
if :fltdept is not null then
  vwhere := vwhere || 'and deptno = :fltdept ';
end if;
if nvl(:fltsal,0) > 0 then
  vwhere := vwhere || 'and sal >= :fltsal ';
end if;
set_block_property('scott_emp', default_where, vwhere);
end;
 
Created a Push Button to execute query in Scott_Emp block and following is the code written in When-Button-Pressed trigger:
 
go_block('scott_emp');
execute_query;
 
Note: Run the SQL script first to create the table in your current schema before running the form which I provided in source code Prequery_Filter.zip.

Define Custom Data Filter Using Pre-Query Trigger In Oracle Forms的更多相关文章

  1. An Example of On-Error Trigger in Oracle Forms

    I wrote this trigger around 4 years ago to handle errors in an application based on Oracle Forms 6i. ...

  2. Using Post-Form Trigger In Oracle Forms

    Post-Form trigger in Oracle Forms fires during the Leave the Form process, when a form is exited.   ...

  3. Using Pre-Form Trigger In Oracle Forms

    Pre-Form trigger in Oracle Forms fires during the form start-up, before forms navigates to the first ...

  4. Writing On-Error Trigger In Oracle Forms

    Suppose you want to handle an error in oracle forms and want to display custom error message for tha ...

  5. Learn How To Create Trigger In Oracle Forms

    I have written many posts related to triggers in Oracle Forms, I have given examples for Form Level ...

  6. Create Custom Modal Dialog Windows For User Input In Oracle Forms

    An example is given below to how to create a modal dialog window in Oracle Forms for asking user inp ...

  7. Using Post_Query Trigger in Oracle Forms

    When a query is open in the block, the Post-Query trigger fires each time Form Builder fetches a rec ...

  8. Examples For When-Validate-Item trigger In Oracle Forms

    The following example finds the commission plan in the COMMPLAN table, based on the current value of ...

  9. Enter Query Mode Search Tricks Using Enter_Query Built-in in Oracle Forms

    In this post you will learn how to specify any condition in enter query mode of Oracle Forms. Whenev ...

随机推荐

  1. Windows核心编程小结1

    这本书绝对经典,看看定会增加不少知识.当然这本书有很多东西比<Windows程序设计第五版>中的更加详细. 1.Unicode:宽字节字符集 这是一个国际的字符标准,16位,最大可支持65 ...

  2. Python-S9——Day100-Web前端框架之Vue

    01 课程简介: 02 let和const: 03 箭头函数: 04 对象的单体模式: 05 nodejs介绍和npm操作: 06 webpack.babel介绍和vue的第一个案例: 07 昨日内容 ...

  3. jquery左右滑动菜单

    <div class="mini-container" style="position:relative;height:100%;"> <di ...

  4. Leetcode 558.四叉树交集

    四叉树交集 四叉树是一种树数据,其中每个结点恰好有四个子结点:topLeft.topRight.bottomLeft 和 bottomRight.四叉树通常被用来划分一个二维空间,递归地将其细分为四个 ...

  5. Spring MVC与jQuery结合使用Ajax技术

    gradle配置 group 'org.zln.webDemo' version '1.0-SNAPSHOT' apply plugin: 'java' apply plugin: 'jetty' s ...

  6. 快乐的Linux命令行

    ls - 列出目录内容 -a 列出所有文件 -d 指定目录信息 -F 为目录增加/标识 -h 增强可读性 -l 列模式显示 -r 反序显示 -S 按照大小排序 -t 按照修改时间排序 file - 确 ...

  7. POJ 2836:Rectangular Covering(状态压缩DP)

    题目大意:在一个平面内有若干个点,要求用一些矩形覆盖它们,一个矩形至少覆盖两个点,可以相互重叠,求矩形最小总面积. 分析: 数据很小,很容易想到状压DP,我们把点是否被覆盖用0,1表示然后放在一起得到 ...

  8. git下载其他人分支的代码

    1. 在工作空间,右键,打开Git Bash 2. clone主分支的代码(即下载主分支代码的过程) 执行命令: git clone xxx.git 3. 进入工程目录 cd   xxx 4. 切换到 ...

  9. python获取目录下文件夹名称

    path = '/opt' dirs = os.listdir(path) for dir in dirs: print dir

  10. /bin , /sbin , /usr/sbin , /usr/local/sbin 的区别

    usr 是 UNIX Software Resource 的缩写,也就是 Unix操作系统软件资源 所放置的目录. 一 /bin:Essential user command binaries(for ...