Karen Cannell kcannell@thtechnology.com APEX: Tight Tabular Forms Karen Cannell kcannell@thtechnology.com http://www.thtechnology.com
Volunteer to author ODTUG Journal Articles! About Me … Karen Cannell ~ Consultant, TH Technology Analyzed, designed developed, converted, upgraded, enhanced and otherwise worked on database applications for 25+ years, focused on Oracle since 1994. Currently migrating business processes from paper to web-based systems, leveraging the Oracle 10g & 11g suite of tools. Lately APEX. Editor, ODTUG Technical Journal Volunteer to author ODTUG Journal Articles! Using APEX since the HTMLDB beginning
About You … (Audience Background) New to APEX? APEX Experience? Previous Tools? APEX Training? Version 2.0? 3.1 ? 3.2 ? 4.0?
Agenda Tabular Forms, <= APEX 3.2 Tabular Forms, Manual Loose Tabular Forms, Manual Tighter and Tedious Tabular Form 4.0 Enhancements Tighter, less work OOTB Tabular Form 4.0 + Custom Tightest and (a bit) less Tedious
Tabular Forms Multiple Rows, Columns at Once
Tabular Form vs. Updateable Report Coding w/the Enemy: JDeveloper as PL/SQL IDE April 26, 2006 Tabular Form vs. Updateable Report Tabular Form = = Updateable Report Report + editable items + MRU, MRD, Add Row Processes. Try adding fly-in HTML, CSS, XML, JavaScript URL COLLABORATE '06 Paper 532
Tabular Forms <= APEX 3.2 ~ Loose ~
The Problem? (<= APEX 3.2) Limited Out-of-the-Box Validations Required, Format Mask Column Checks Only No Per Row No “Has Row Changed?” Error Message Stops on First Error Does Not Show Row/Column of Error Too Loose! Bad Data In … Bad Data Out … Need to Tighten Up …
Tabular Forms <= APEX 3 Tabular Forms <= APEX 3.2 Plus Manual Validations ~ Tighter, Tedious ~
Tabular Form No Element Names Where to Add Validations?
Tabular Form Validations - Solutions Use a Developer Framework i.e. APEXLib Manually Code Validations
APEXLib APEXLib Development Framework http://apexlib.oracleapex.info/index.html#index For APEX <- 3.2, Tabular form Enhancements Help Not an Oracle Product Not part of APEX
APEXLib Tab Form Features Reference columns by name without having to find which array your column is mapped to To get the correct number of rows to process Identify which row has changed Get your data with the correct data type (NUMBER, DATE) without having to take care about format masks. Add a required column check by declaration, instead of coding it. Get more meaningful error message than APEX provides. These Features are in APEX 4.0
To Manually Code Validations: Get the Generated Item Names or Use APEX_ITEM in SQL Query then Use APEX_APPLICATION.g_fxx Arrays to Manually Write Validation/Processing Procedures
Generated Item Names Each Item has a Handle Handle Aligns with an per Wizard’s Standard Naming Convention Handle Aligns with an APEX_APPLICATION.g_fxx Array
WebDeveloper Show ID & Class Details
Manual Tab Form Processing Has the Row Changed?
Tabular Forms APEX 4.0+ ~ Tighter, Less Work ~
APEX 4.0 Tabular Forms Validations!! NOT NULL Column String Comparison e.g. value is numeric, value is a date, value only contains the following characters etc. Error Message Error Cell Highlighting
Tabular Form - Validations
Tabular Form - Validations Columns
Tabular Form Validations NOT NULL String Comp
Tabular Form – String Comp String Comparison Options
Tabular Form Validations Error Display Location
Tabular Form – Error Messages Column and Row
Tabular Form Validations Page
Tabular Form Validations - Page SQL, PL/SQL Use APEX_APPLICATION.g_fnn Arrays
4.0 Tabular Forms - Limitations Cannot Directly Reference Column Values i.e. like Page Items Field Highlighting Only via Declarative Validations Default NOT NULL Validations Do Not Highlight LOV Columns Do Not Highlight Limited Options “… We have plans to further extend this to support additional types of validations in future release of Application Express.”
Tabular Forms 4.0 - Limitations Coding w/the Enemy: JDeveloper as PL/SQL IDE April 26, 2006 Tabular Forms 4.0 - Limitations No Declarative Per-Row Validation No Declarative Page Validation (ok) No Easy Reference to Tabular Form Cells Field Highlighting Only Through Declarative Validations To Code These Use: APEX_ITEM in Query APEX_APPLICATION.g_f0nn Arrays Javascript Still LOTS OF CODE! http://htmldb.oracle.com/pls/otn/f?p=31517:176:2983426600843482 COLLABORATE '06 Paper 532
Tabular Forms APEX 4.0+ Plus Manual Validations ~ Tightest, Less Tedious ~
Manual Tabular Forms - Possibilities Highlight Rows Disable Columns Custom Validations Row-level, Page-level, Complex Whatever You Can Code Second Tabular Form on page Whatever You Can Code!
Generated Item Names Each Item has a Handle Handle per Wizard’s Standard Naming Convention Per APEX_ITEM Call Handle APEX_APPLICATION.g_fxx Array
WebDeveloper Show ID & Class Details
Manual Tabular Forms User APEX_ITEM in Query to Build Element Embed JavaScript in the APEX_ITEM call Use APEX_APPLICATION.g_f0nn Arrays to Code Custom Validations, Other Processing Essentially, you are Manipulating Arrays …
SQL for Manual Tabular Form: Regular SQL Query
Manual SQL for Tabular Form
Resulting Item Names
APEX_ITEM.TEXT Call Syntax:
APEX_ITEM.TEXT Example
APEX_ITEM.TEXT - Sorting
APEX_ITEM.MD5 - Checksum Use When Need Checksum Use for Has Row Changed Checks
APEX_APPLICATION.g_fXX Arrays
PL/SQL to Process Manual Tab Form Use APEX_APPLICATION.g_f0n arrays to Process Data Example: Landed Lbs Must = Landed Qty If Unit = ‘LB’
Landed Lbs Must = Landed Qty If Unit = ‘LB’ Pseudocode: IF g_f13=‘LB’ THEN IF g_f11 <> g_f12 THEN .. ‘Landed Lbs must match Landed Qty when Unit is LB’; END IF;
The Real Code – Assessment Form Validation DECLARE v_msg VARCHAR2(4000) := ' '; v_br VARCHAR2(6) := '<br>'; BEGIN FOR i IN 1 .. APEX_APPLICATION.g_f11.COUNT LOOP IF APEX_APPLICATION.g_f13(i) = 'LB' THEN IF APEX_APPLICATION.g_f11(i) <> APEX_APPLICATION.g_f12(i) THEN v_msg := v_msg ||'Row '||TO_CHAR(i) ||‘ - Landed Lbs must equal Landed Qty if unit is LBs‘ ||v_br; END IF; END LOOP; RETURN v_msg; END
Tabular Forms – Workarounds Manual Tabular Forms APEX_ITEM to build query, APEX g_f0nn arrays Validations not covered by APEX By-Row Validations Embed JavaScript for all those extras: Highlighting Cascading LOVs Conditional Validations Development Framework (ex: APEXLib - Tab form help for < APEX 4.0) Still LOTS OF CODE!!!
Manual Tabular Forms - Possibilities Highlight Rows Disable Columns Custom Validations Row-level, Page-level, Complex Whatever You Can Code Second Tabular Form on page Whatever You Can Code!
Tabular Form - Manual Manual Tabular Form Using APEX_ITEM
Manual Tab Form Processing Has the Row Changed?
Tabular Form - Online Examples Great Examples at Denes Kubicek http://htmldb.oracle.com/pls/otn/f?p=31517:170 Many others out there!
Manual Tabular Forms Demo ~ in case I forgot ~
Tight Tabular Forms - Summary <= APEX 3.2 No Validations Anything can get in APEX 4.0 + Out-of-the-Box Validations Improves Still only part way there! Unless You Build It … Be Prepared to Code, Still …
References APEX_ITEM Documentation APEX_APPLICATION Documentation http://download.oracle.com/docs/cd/B28359_01/appdev.111/b32258/api.htm#HTMDB15003 APEX_APPLICATION Documentation http://download.oracle.com/docs/cd/E10513_01/doc/apirefs.310/e12855/apex_app.htm APEX Documentation and Examples http://apex.oracle.com Denes Kubicek (Tabular Form Examples) http://htmldb.oracle.com/pls/otn/f?p=31517:170 APEXLib (Tabular Form Help) http://apexlib.oracleapex.info/
K’Scope 2011!!
Share Your Knowledge ! Call for Articles/Reviewers ODTUG Technical Journal ALWAYS Looking for Content! kcannell@odtug.com
Please fill out the evaluations! Questions ? Tight Tabular Forms kcannell@thtechnology.com http://tunahuntress.com/apex Please fill out the evaluations!
Please fill out the evaluations! Tight Tabular Forms February 2011 Thank You ~ Tight Tabular Forms kcannell@thtechnology.com http://tunahuntress.com/apex Please fill out the evaluations! RMOUG 2011 Karne Cannell, THTechnoloy
<= 3.2 Tabular Form - Drawbacks Limited Validations on Columns No Row-Changed Function Error Messages Do Not Indicate Row/Column Stops After First Error To Code Validations, use APEX_APPLICATION.g_fxx Arrays All Custom Code If Order Changes, Re-Code Conditions Change g_fxx Array Checkbox Columns Use g_fxx Arrays Differently …
Tabular Form - Manual Manual Tabular Form Using APEX_ITEM