iSelfSchooling.com  Since 1999     References  |  Search more  | Oracle Syntax  | Free Online Oracle Training

    Home      .Services     Login       Start Learning     Certification      .                 .Share your BELIEF(s)...

 

. Online Accounting        .Copyright & User Agreement   |
    .Vision      .Biography     .Acknowledgement

.Contact Us      .Comments/Suggestions       Email2aFriend    |

 

Online Oracle Training for beginners and advanced - The most comprehensive Oracle tutorial

The authors do not guarantee or take any responsibility for the accuracy, or completeness of the information.

Developers - FORMS

 

Lesson 01 | Lesson 02 | Lesson 03 | Lesson 04 | Lesson 05 | Lesson 06 | Lesson 07 | Lesson 08 | Lesson 09 | Lesson 10 | Lesson 11 | Lesson 12 | Lesson 13 | Lesson 14 | Lesson 15 | Lesson 16 | Lesson 17 | Lesson 18 | Lesson 19 | Lesson 20 | Lesson 21 | Lesson 22 | Lesson 23 |

 

Lesson 22

"The true measure of a man is how he treats someone who can do him absolutely no good." - Samuel Johnson (1709-1784)

 

Parameters between FORMS

 

Introduction

Let"s suppose that you have two forms named EMPLOYEES and DEPARTMENTS. In the EMPLOYEES form, if your cursor is pointing at the "deptno" item when you click on a push button (For example: Show me department information") you would want it to open a window to display all information about that department.

Before reading the following hands-on exercise, you should have all ready completed at least the "Introduction to Form Builder" hands-on. To avoid repetition, we assume that, you are at least familiar with where the icons and sub-menus are.

 

Step 1:

Create DEPARTMENT form

Create the "DEPARTMENT" form as you create any other form. Create a parameter and name it p_deptno. Open the parameter"s property palette and change the Parameter Data Type field to "Number," the Maximum Length field to "2," and the Parameter Initial Value field to "10." Open the data block properties (DEPT) and in the "WHERE Clause" property type deptno = :parameter.p_deptno. Then create the "WHEN-NEW-FORM-INSTANCE" triggers on form level and type "execute_query;" then compile the procedure.

 

Step 2:

Create EMPLOYEES form

Create the "EMPLOYEES" form as you create any other form including the tabular, and 10 records at a time options, and check mark "Display Scrollbar" option.

Create a control block and then create a push button in that block. Open the push button"s property palette and change the "Name," and "Label" fields. The "label" value should be "Show me department information"" Create the "WHEN-BUTTON-PRESSED" trigger and type the following code:

(Form Builder)

DECLARE

p_id paramList; -- This is a variable that contains id of the parameter list

p_name VARCHAR2(20); -- A variable that keeps your parameter name

 

BEGIN

p_name := 'myparameter';

p_id := GET_PARAMETER_LIST('p_name'); -- find it if exists.

 

IF NOT ID_NULL (p_id) THEN

-- If exit then destroy it.

DESTROY_PARAMETER_LIST(p_id);

END IF;

 

--Now create a parameter list and add your p_deptno parameter.

p_id := CREATE_PARAMETER_LIST('p_name');

ADD_PARAMETER(p_id,'P_DEPTNO',TEXT_PARAMETER,to_char(:deptno));

 

--- You can call the called program either by default or specific like c:.

OPEN_FORM('c:',ACTIVATE,SESSION,p_id);

 

-- Error messages in case the called program was not able

-- to open called program.

IF NOT FORM_SUCCESS THEN

MESSAGE('ERROR: Unable to open the DEPARTMENT form.');

RAISE FORM_TRIGGER_FAILURE;

END IF;

 

EXCEPTION

WHEN others THEN

MESSAGE ('Error: unable to create parameter list"');

RAISE FORM_TRIGGER_FAILURE;

END;

 

Step 3:

Compile the DEPARTMENT form

Make sure that you have compiled the DEPARTMENT form.

 

Step 4:

Test the application

Now, you should be able to test. Execute the query on the EMPLOYEES table and move your cursor to any record that you need to know more information about its department. Then click on the "Show me department information" push button. You should see complete information about that department.