1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
Subject: Passing Parameters Between Forms Using Shared Library and Global Record Group
Doc ID: Note:73307.1 Type: BULLETIN
Last Revision Date: 12-JUL-2007 Status: PUBLISHED
Introduction:
=============
This note will try to help with the following questions:
- HOW TO PASS PARAMETERS BETWEEN FORMS?
- HOW TO FIND OUT IF A SET OF FORMS ARE OPENED AND IF SO, WHAT IS THE
STATUS OF THE FORM - WHETHER QUERY_ONLY OR NOT?
- WHAT IS A SHARED LIBRARY TECHNIQUE?
In Forms 5.0 + you could use a shared PL/SQL library (see the Forms online help
on CALL_FORM and OPEN_FORM on how to define this). The Library could contain a
PL/SQL package with a public variable of length 2000. Two forms could write to
and read this variable. This will only work if the two forms share the same
session.
Shared PL/SQL Library:
======================
The shared library technique in Forms 6.0 + includes the following:
1) You have a common library which is attached to all your forms.
2) Within the library you have a PL/SQL package which you define an array of
PL/SQL records. For example:
package FORM_LIST is
TYPE tFormData is Record (FormName VARCHAR2(30), QueryOnly BOOLEAN);
/* plus any other data you want to store */
TYPE arrFormData is table of tFormData index by binary integer;
-- Now the public array
FormData arrFormData;
end;
3) When you open or call any forms that you wish to share this library with,
you do so with the SHARE_LIBRARY_DATA option in the CALL_FORM or OPEN_FORM.
CALL_FORM('form2',hide,no_replace,no_query_only,SHARE_LIBRARY_DATA);
4) You insert a value into the PL/SQL table whenever you call or open a new form.
You can use the id of the form (the value you get using FIND_FORM) to act as
the index for the PL/SQL table using the notation FormId.ID to get a pls_integer
version of the form id.
5) The Library could contain a PL/SQL package with a public variable of length
2000. Both forms could write to and read this variable. This only works if
the Forms share the same session.
Advantages of using shared library:
-----------------------------------
1) If you need to pass composite types like EMP%ROWTYPE, then use a package
in a PL/SQL library that is shared by the two forms in question.
2) For passing Forms types such as FORMMODULE, ITEM, WINDOW etc. then you
can pass these as an integer by accessing the ".ID" of the object.
This technique works but is not documented - e.g use at your own risk.
Example:
declare
MyForm FORMMODULE;
FormID NUMBER;
begin
MyForm := FIND_FORM('EMP_DATA')
FormId := MyForm.ID;
/* Then pass FormId as a normal Number param or even in a Global */
end;
Because you have used SHARE_LIBRAY_DATA, all of the forms share the same instance
of the PL/SQL package and hence the same instance of the PL/SQL table. So you could
do something like:
declare
hFormId FORM;
begin
hFormId := FIND_FORM(:SYSTEM.CURRENT_FORM);
if FORM_LIST.FormData(hFormId.id).QueryOnly then
/* this is going to return the boolean variable of queryonly is true or false */
.....
end if;
end;
Question:
---------
Why PARAMLIST packaged variables in library cannot be shared among the forms
even though DATA_MODE is SHARE_LIBRARY_DATA?
Answer:
-------
SHARE_LIBRARY_DATA provide sharing of package variables only. So the ID of
parameter list may be shared, but the actual list is not. |
Partager