1. How to build Multi-Client APEX Applications
Reduce the number of applications and schemas required to serve clients with
similar needs but different data while maintaining privacy and personalization.
By Tony Jedlinski President Konoso LLC
2. Tony Jedlinski
President - Konoso LLC
Vice President - MOUG
Former Executive VP, Director Web Content and Initiatives - IOUG
•Recognized by Oracle Magazine as a leading expert in Oracle Application Express (ApEx) development
(named HTML-DB Developer of the year – 2005).
•Published ApEx author (Oracle Magazine May/Jun 2006), (IOUG SELECT Journal Q4 2005).
•ApEx presenter (Oracle World 2004, 2006, 7), (IOUG Live! 2004,5), (Collaborate 2006,7,8,9,10,11).
•More than 25 of years experience as an Oracle systems architect / developer, and 35 years of
experience in system analysis and development.
3. The idea
Sometimes multiple users have the basically
same needs but require some
customization, for example Oracle User
Groups
When working on a tight budget,
you may not have the luxury of
separate schemas for each client,
rather you may need to have
multiple clients share the same
tables and other objects.
Having everyone sharing the same
application and underlying data
structure can reduce support and
maintenance cost and time.
4. Customization is still possible using these techniques
• Automatically selected theme roller themes
• Option settings
• Saved settings (e.g. logo file location) in database
• Custom Dictionary Values
• Use application level variables to substitute variable text e.g.
Organization Name
5. Setup
• Determine at what level(s) you will customize (e.g. Organization)
• Add a foreign key column to the USER dictionary to identify which
Organization the user belongs to.
• Use this same technique for other tables such as dictionaries
6. Setup
ACP_MHBS table defines the Organizations
Each user is associated with a particular Organization and given appropriate
privileges and personality
7. Set application level fields to easily reference the User’s Organization
Do not allow these fields to be set from the browser .
Re-calculate them on every page display so that any
setting changes are reflected immediately.
8. Now report queries etc. can be limited to just the rows of the current user’s
Organization
9. Changing Theme Roller settings dynamically
• Based on current user
• Based on current user’s affiliation (e.g. Organization)
• Any other entity in the database
12. PL/SQL Procedure holds
the complexity
The code to manipulate styles is in
the APEX_THEME package provided
by Oracle
Look up the current style and the
desired style tor the user’s
Organization.
If they are different, set to the desired
style using
apex_theme.set_user_style
17. Complexity is within the function HAS_OPTION
CREATE OR REPLACE FUNCTION has_option (acp_mhb_num_in IN
PLS_INTEGER, option_code_in IN VARCHAR2)
RETURN VARCHAR2
AS
CURSOR o_cur
IS
SELECT *
FROM options
WHERE code = UPPER (option_code_in);
result_v VARCHAR2 (1) := 'N';
BEGIN
FOR o_rec IN o_cur
LOOP
IF INSTR (':' || o_rec.acp_mhb_nums || ':', ':' ||
TRIM (TO_CHAR (acp_mhb_num_in)) || ':') > 0
THEN
result_v := 'Y';
END IF;
END LOOP;
RETURN result_v;
END;
/
Look up the Organization(s) who have this
option.
If the current Organization is included,
return Y else return N
18. Add this authorization to the appropriate page element(s),
in this case the entire EMP page and it’s navigation bar entry.
29. Dynamic Application level variables
• Personalize text areas (e.g. Report titles) by setting and referencing a
dynamic application variable For example SHORT_NAME.