Sunday, December 18, 2016

 Auto-Refresh Data Block Timer's Trick  



In the name of Allah, Most Gracious, Most Merciful
Praise be to Allah, blessing and peace be upon our prophet Mohammed, his family and his companions. After that,


     You may work in a critical work area where the change of data on time means a significant importance of the business data flow work progress.


    Data change controls the logical work flow the user expects 

      The start or the end of customer business transaction like:
  • The bank customer's queue needs an instance data refresh with the flow of  the in-coming bank-customers to determine the next customer's transaction or its end. 
  • The patient's role management control for doctors and nurse station in a medical clinic depends on the data of patient's attendance time. 

    Data change motivates your customer to make his purchasing decision.

       The daily or instance data change controls the client's decision like: 
  • The instant Stock prices change for shareholders needs a dynamic update or an auto-refresh for data blocks.
  • The daily foreign currency trading in the exchange companies and banks.
       
        Consequently, it is a significant task we need for a specific needs to fulfill the  requirements of your system application user.  On the other hand, Oracle form has not a direct control to auto-refresh you data block. But it gives you a free use of a timer where you can use it in different purposes.  Thus, let's start some simple work around using Oracle Forms' Timer.  


Task Definition:   

       Data Block Auto-Refresh


Task Solution:

        Initially, we need to know that the  timer is not an object but it is actually an internal clock you pro-grammatically create and manipulate displaying data automatically. So let's create a timer as follow...


Create a Timer:
  1.    Declare a variable of timer data type.
  2.      Initialize a variable with one second number data type.
  3.      Use a CREATE_TIMER built-in with the timer's name, interval and it's status  repeats every one second on timer's expiration.
  4.      Assign the timer's creation built-in to a variable of timer data type. 
  5.   In  WHEN-NEW-FORM-INSTANCE trigger Form-Level paste the following:    
DECLARE
   timer_id   Timer;
   one_sec    NUMBER (5) := 60000  ;   -- 1 minute in milliseconds
BEGIN
   timer_id := CREATE_TIMER ('MYTIMER', one_sec, REPEAT);
END;
                                    
    
       Delete a Timer:

       
       In timer's creation and expiration one second  created, executed in regards to current system date. It repeats itself endlessly. 
Paste the following code in When-Timer-Expired Trigger Form-Level :

BEGIN
EXECUTE_QUERY(NO_VALIDATE);
END; 
       
         
       In the previous example, i assumed you have one data block with multi-records.

       Now, you can compile, generate and  run the form, if it works then save your form as a ready made example you can refer to in a need.

       Let's assume, you have two  data blocks, you have to specify a logical master-detail relationship according to your table database master and detail relationship.
 Then, paste the following code in When-Timer-Expired Trigger Form-Level :


BEGIN
Go_block('block_name');
EXECUTE_QUERY(NO_VALIDATE);
END; 
   
      This is a simple data block refresh example without any restriction or conditions. 

If you want to Filter the data display into your block, then You have to follow one of the two ways:
  • Block Property: The master data block property > where clause.
  • Pro-grammatically: using the default_where clause.

     If you want to Order the data display into your block, then You have to follow one of the two ways:
  • Block Property: The master data block property > Order By clause.
  • Pro-grammatically: using the Order by using SET_BLOCK_PROPERTY built-in.

  

 Learn more about:


        ·       In-Direct Global Variable Access
   ·     Menu Item Enable/Disable



Hope this helps...


My success only comes from Allah, pls. note your comments and suggestions are great help for me in progress thanks in advance.