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. [netty4][netty-common]Future与Promise分析

    接口与类结构体系 -- [I]java.util.concurrent.Future<V> ---- [I]io.netty.util.concurrent.Future<V> ...

  2. php代码审计 strcmp和MD5函数漏洞

    通过get得到三个值,v1,v2,v3. if第一层判断,v1和v2得到的值不一样,但是对它们进行md5加密后的值得相等. if第二层判断,v3得到的值得和$flag的值相等,满足这两个条件输出fla ...

  3. Wordpress 通过 post id 获取文章 url

    global $post; echo get_permalink($post->ID); 函数详解: Codex - get_permalink() 注意:有些链接是通过 SEO 重定向的,比如 ...

  4. Leetcode 639.解码方法2

    解码方法2 一条包含字母 A-Z 的消息通过以下的方式进行了编码: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 除了上述的条件以外,现在加密字符串可以包含字符 ' ...

  5. C#如何定义一个变长的一维和二维数组

    1.假设将要定义数组的长度为程序执行过程中计算出来的MAX List<int> Arc = new List<int>(); ; i < MAX; i++) { Arc. ...

  6. cf 853 B Jury Meeting [前缀和]

    题面: 传送门 思路: 看完题目以后,首先有一个结论:每个人都是先去到首都,等待开会,开会结束以后再一个个走掉 而且这道题只有去首都和离开首都的机场 因此考虑计算去首都的飞机的前缀最小花费,以及离开首 ...

  7. set和dict

    dict属于mapping类型 from collections.abc import Mapping,MutableMapping from collections.abc import __all ...

  8. iOS中block 静态全局局部变量block变量,以及对象,详解!

    //最近总是犯迷糊,关于block对外部变量的引用,今天有时间就写了一下,加深自己的理解,巩固基础知识 1 #import <Foundation/Foundation.h> ; int ...

  9. C#可选参数与具名参数

    可选参数 static void test1() { func1("A"); func1(); Console.ReadKey(); } ) { Console.WriteLine ...

  10. 用来武装Firebug的十四款Firefox插件

    原文发布时间为:2010-04-24 -- 来源于本人的百度文章 [由搬家工具导入] 如果你是一名Web设计师,Firebug想必不会陌生,作为一款Firefox插件,它可能是网站前端开发最有用的工具 ...