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. Linux之匿名FTP服务器搭建

    FTP(File Transfer Protocol)是在服务器与客户端进行文件传输的一种传输协议.本次介绍的是vsftpd的软件体验ftp服务. FTP服务器默认情况下依据用户登录情况分为三种不同的 ...

  2. 【POJ 3764】The Xor-longest Path

    题目 给定一个\(n\)个点的带权无根树,求树上异或和最大的一条路径. \(n\le 10^5\) 分析 一个简单的例子 相信大家都做过这题: 给定一个\(n\)个点的带权无根树,有\(m\)个询问, ...

  3. 菜鸟之路——Linux基础::计算机网络基础,Linux常用系统命令,Linux用户与组权限

    最近又重新安排了一下我的计划.准备跟着老男孩的教程继续学习,感觉这一套教程讲的很全面,很详细.比我上一套机器学习好的多了. 他的第一阶段是Python基础,第二阶段是高等数学基础,主要将机器学习和深度 ...

  4. Socket 编程中,TCP 流的结束标志与粘包问题

    因为 TCP 本身是无边界的协议,因此它并没有结束标志,也无法分包. socket和文件不一样,从文件中读,读到末尾就到达流的结尾了,所以会返回-1或null,循环结束,但是socket是连接两个主机 ...

  5. web访问流程

    客户端发送请求—->httpd得到请求—->httpd解析请求的格式(html,css,jsp)—->请求相应的PHP解析—->PHP解析程序执行完毕—–>db(数据库) ...

  6. iOS 代理为啥要用weak修饰?

    在开发中我们经常使用代理,或自己写个代理,而代理属性都用weak(assign)修饰,看过有些开发者用strong(retain),但并没发现有何不妥,也不清楚weak(assign)与strong( ...

  7. 部署私有Docker Registry

    安装部署一个私有的Docker Registry是引入.学习和使用Docker这门技术的必经之路之一.尤其是当Docker被所在组织接受,更多人.项目和产品开始接触和使用Docker时,存储和分发自制 ...

  8. BZOJ【1606】购买干草

    1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 859  Solved: 63 ...

  9. Javascript&Html-系统对话框

    Javascript&Html-系统对话框 浏览器通常内置三种对话框,他们分别是 alert(),confirm()以及prompt() .这三种对话框的外形跟页面的HTML以及CSS均没有任 ...

  10. Entity Framework context per request

    原文发布时间为:2011-09-24 -- 来源于本人的百度文章 [由搬家工具导入] http://www.blog.cyberkinetx.com/2011/05/15/entity-framewo ...