2010年4月13日 星期二

SET_BLOCK_PROPERTY - DEFAULT_WHERE應用


假設我們現在要查xyz資訊工坊 員工編號在 1000~2000 之間,且姓王的員工

<
查詢畫面>
Block Name : B_QUERY_FIND
Item Name : emp_name "
員工姓名" , emp_no_beg "員工編號起" , emp_no_end "員工編號迄"

<
主畫面>
Block Name : B_MAIN
Item Name : emp_name "
員工姓名" , emp_no "員工編號"

xyz 因為兩個 Block 的員工姓名資料是可以 maping 的,
B_MAIN block level trigger : PRE-QUERY 中加上
copy( :B_QUERY_FIND.EMP_NAME , 'B_MAIN.EMP_NAME' );

如此不管在 :B_QUERY_FIND.EMP_NAME 打完整名稱,或以 % 來查詢都可以

因為員工編號的查詢條件是以區間來查詢,所以在  FIND Button 中處理
declare
   ls_where         varchar2(1000);
   ls_this_where    varchar2(1000);
begin
   if     :b_query_find.emp_no_beg is null
      and :b_query_find.emp_no_end is null
   then
      :parameter.g_query_find := 'FALSE';
      Fnd_Message.Set_Name('FND','You Must Enter Employee Number !!');
      Fnd_Message.Error;
   else
      ls_where := GET_BLOCK_PROPERTY('B_MAIN',DEFAULT_WHERE);
      if  ls_where is null
      then
         ls_this_where := '1=1 ';
      else
         ls_this_where := ls_where;
      end if;
      if    :b_query_find.emp_no_beg is not null
      then
         ls_this_where := ls_this_where||' and emp_no >= :b_query_find.emp_no_beg';
      end if;
      if    :b_query_find.emp_no_end is not null
xyz資訊工坊       then
         ls_this_where := ls_this_where||' and emp_no <= :b_query_find.emp_no_end';
      end if;
      SET_BLOCK_PROPERTY(''B_MAIN',DEFAULT_WHERE,LS_THIS_WHERE);
      app_find.find('B_MAIN');
      SET_BLOCK_PROPERTY('B_MAIN',DEFAULT_WHERE,LS_WHERE);
   end if;
end;
:parameter.g_query_find := 'FALSE';

以此例而言 :
:B_QUERY_FIND.EMP_NAME := '
%'
:B_QUERY_FIND.EMP_NO_BEG := '1000'
:B_QUERY_FIND.EMP_NO_END := '2000'


沒有留言:

張貼留言