Sunday, June 28, 2015


 Closing Multiple Windows 


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,


     A window is just a container for all logical visual attributes that make up a Form Builder application. A single form may include several windows. You must create at least one content canvas for each window, but only one content canvas can be displayed at run-time, even though more than one content canvas can be assigned to the same window at design time.

Key Problem:
 When clicking the close ('X') ICON of the current window, another existing window is getting opened which is not desirable feature.


Key Reason:
 There is no default behavior in closing Oracle Window Forms; when a user chooses the Close Menu item or the upper right ('X') icon. The window form will not automatically close. You must define a form-level trigger "When-window-closed" with such associated built-ins or system variables.   


Key Solution:

When-Window-Closed trigger:

     
      In regard to Single Oracle Window  form, you can use the mentioned trigger  to  close a window pro-grammatically when the operator issues a window manager–specific close command. Issuing the close command is just perfect for a single window form.


 EXIT_FORM;

     In regard to multiple Windows form consider "SYSTEM.EVENT_WINDOW" system variable. It keeps the name of the last window for which a window interaction trigger fired. You can also use this system variable to perform different actions for different windows in your window interaction triggers.



You can close a window using built-ins.

HIDE_WINDOW,SET_WINDOW_PROPERTY, and EXIT_FORM 


WHEN-WINDOW-CLOSED trigger example at form-level...

      
Suppose you have more than a window (WINDOW1, WINDOW2 ...)
 You can perform closing each window by using the following system variable
" SYSTEM.EVENT_WINDOW".



IF :SYSTEM.EVENT_WINDOW='WINDOW1' THEN

  -- Do something while closing window1/canvas1 

         DO_KEY('exit_form');


ELSIF :SYSTEM.EVENT_WINDOW='WINDOW2' THEN

  -- Do something while closing window2/canvas2 

  HIDE_WINDOW('WINDOW2');

   ... etc.

END IF;



Or you can use the following built-ins in "WHEN-WINDOW-CLOSED" trigger 
  


HIDE_WINDOW('current_window_name');

SHOW_WINDOW('main_window');

GO_BLOCK('block_name');

GO_ITEM('next_window_item');


...This applies on any form window types or forms version

The following Link is:


    Learn more about:


·          Dependent Drop Down list


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.


Friday, June 19, 2015

Create a Dynamic List Item




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,


Task Definition: Create a Dynamic List Item

Let's have a quite simple application, e.g. "Club Membership" application involved  two simple tables 'YEARS' and 'MEMBERS' with two abstract column contents; id and name column for each table individually. Now, we want to populate two list items dynamically for each individually.



Task Execution Idea:  You can follow the following logical steps to accomplish the task safely and properly...


Procedure


   ''ADD_LIST_ELEMENT''Using the following procedure 

        Syntax

       ADD_LIST_ELEMENT(list_id ITEM, list_index VARCHAR2, list_label VARCHAR2, list_value VARCHAR2);

o   Syntax Specifications

o   list_id: Specifies the unique ID that Oracle Forms assigns when it creates the list item.
o   Use the FIND_ITEM built-in to return the ID to an appropriately typed          variable.  The data type of the ID is ITEM.
          Example:  v_ stage  ITEM  := FIND_ITEM ('STAGE.st_id');
o   list_index:  Specifies the list index value.  The list index is 1 based.
o   list_label  Specifies: the VARCHAR2 string that you want displayed as the label of the list element.
o   list_value:  The actual list element value you intend to add to the list item.
o   Get_List_Element_Value: access the current index number for each loop independently. 

·        This procedure adds only a single element to a list item. 
·        This is not practical for multi-list values…

So it's more logical to think about looping through the whole database records stored in your 'List Item' table.
          Consequently, it's more appropriate use For…. Loop structure.
   
·      It's a dynamic procedure; it executes run-time. You have to free the memory from any old value to get actual and correct values result

·      built-ins used as needed:

o   CLEAR_LIST Built-in: Clears all elements from a list item. After Oracle Forms clears the list, the list will contain only one element the 'Null' value, regardless of the item's required property.
o   GET_LIST_ELEMENT_COUNT Built-in: Returns the the current index of the list item.

. 
Task Solution: 


Let's follow the above mentioned solution idea concerning…


 
ADD_LIST_ELEMENT(list_id ITEM, list_index VARCHAR2, list_label VARCHAR2, list_value VARCHAR2);


Pls. Follow the logic of the following steps to do the task safely and properly...



DECLARE

     v_count    NUMBER := 1 ;

     CURSOR  year_cur  IS SELECT year_id , year_name
                                          FROM  YEARS ORDER BY  year_id;

     v_ year  ITEM  := FIND_ITEM ('YEARS. year_id');


    CURSOR  member_cur IS SELECT member_name , member_id
                                           FROM  MEMBERS ORDER BY member_id ;

    v_ member ITEM  := FIND_ITEM ('STAGE. member_id');

BEGIN 
                   
     CLEAR_LIST (v_ year);

     FOR  m in year_cur LOOP

/** Get_List_Element_Value access the current index number for each loop independently.
This helps Determine the total number of list elements. **/

     ADD_LIST_ELEMENT t(v_ year  , GET_LIST_ELEMENT_COUNT(v_ year)+1,  m. year_name , TO_CHAR(m. year_id));

END LOOP;


/* The traditional technique */


  CLEAR_LIST (v_ member);
   
 FOR  z in member_cur LOOP

     ADD_LIST_ELEMENT (v_member, v_ member +1 , z. member_name , TO_CHAR (z. member_id ));

 END LOOP;

END;


Note:

o   You may face a Compilation error i.e.
  FRM-30351: No list elements defined for list item
  and a run time error i.e. unable to resolve reference to the item...
o   Although you fill your list item dynamically at runtime, but the 'Null' value always displays in the List Item.
      
           Key Reason: By default, the property of the list item 'Required' is set to 'YES'.
  
       Key Solution:

               *       Reset List item property: 'Required' value to 'NO'.
               *       You must provide 'dummy' values: let's say 0.


For more advanced techniques pls. read dependent drop down list

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.


Wednesday, June 17, 2015


 Oracle Form Global Variable Recognition


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,


Global Variable
·        Global variables has a global scope; it is visible (accessible) throughout your application program.
·        Global variables are used extensively to pass information between forms.
·        Global variables can be created by a PL/SQL assignment, or by the DEFAULT_VALUE built-in.
 


Global Variable Types
Oracle Forms Developer and PL/SQL support different types
  • Oracle Forms Global: a variable in the "global" pseudo-block of a form
  • PL/SQL Package Global: a global defined in the specification of a package
  • Oracle Forms Parameter: a variable created within the Oracle Forms Designer as a Parameter

Pls. see the Oracle Forms Reference Manual for a complete description of these variable types.
 The following table lists the characteristics of each type of variable, and enables you to select the type most appropriate for your code.
Behavior
Oracle Forms Global
PL/SQL Package Global
Oracle Forms Parameter
Can be created at Design time

Y
Y
Can be created at runtime
Y


Accessible across all forms
Y


Accessible from attached libraries
Y
(1)
Y
Support specific data types
(2)
Y
Y
Have declarative defaults


Y
Can be referenced indirectly
Y

Y
Can be specified on command line


Y
Must be erased to recover memory
Y


Can be used in any Oracle Forms code
Y

Y



Global Variable Limitations  

·        Global variables do not generate any compilation errors during development stage but only run-time errors.

·        Global variables are always characters. If you are not familiar with this fact, your expected output will not work; no effect.

       Now Current situation

§    On development stage, at design-time, you will not face any compilation error.
§   On test stage, at run-time you will not face any run-time error.
        You will have  just silent failure with no explanation and sucked helpless. It's                 better to know this case before wasting effort and time.

·     A significant drawback of Global variables; it consumes high memory resources:
§  Memory is an important resource for your application so it’s wise to consider choosing other alternatives for Global variables.
§   Form Parameters are recommended alternative instead of using Global variables.

·     Global variables usage is recommended Not to use them if un-necessary.

·     Global variables persist in memory until you remove it externally with the ERASE () built-in procedure.

·     Global variables must be declared, if Not initialize before execution, it will generate run-time error.

FRM-40815 GLOBAL. does not exist.

              Warning Avoid above error by assigning the appropriate value to                                             the global variable before opening the new form.

·        In fact, they are usually considered bad practice precisely because of their non-locality.


·     Each Global variable Must has the same name to each form session.



          Warning: Oracle recommends explicit conversions, rather than rely on                                         implicit or automatic conversions for these reasons:

·        You will need   using a NUMBER using the TO_NUMBER() function or using TO_DATE() functions. 

   

  For more related detailed Global variables usage pls read 



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.