190 likes | 196 Vues
Track the changes in your Apex application between releases: Yes you can. Plsql based methodology to monitor the changes in your application between releases. Koen Lostrie Developer, Curriculum Development Oracle Corporation March 25 th , 2015 koen.lostrie@oracle.com @koenlostrie.
E N D
Track the changes in your Apex application between releases: Yes you can Plsql based methodology to monitor the changes in your application between releases Koen Lostrie Developer, Curriculum Development Oracle Corporation March 25th, 2015 koen.lostrie@oracle.com @koenlostrie
Program Agenda Introduction Solution Architecture Implementation Demo Q & A 1 2 3 4 5
Introduction How can we know what changed in our application • Good tracking system (team dev/ packaged app/ Jira) where developers document changes. Works really well for tracking features/enh req/bugs. NOT for knowing exactly what changed. • Apex apps are easy to change. There is always the “ah here is a bug let me quickly fix that. No need to document that”. • Audit columns in the apex views give us who and when but not what and old value/new value.
Introduction So what doesn’t work ? • Check the export file – challenge. Big challenge. • Compare the splitted export files – same. • Version control comparison.
Introduction The idea... • How else can we track changes ? • DBMS_COMPARISON. • Oracle Total Recall. • Other Tools (eg COMPARE_SYNC) • But I would like to track changes in the apex views. • That is a view, can’t create a trigger on that • So how about – replicating the apex view data and then auditing changes ?
Introduction I want my solution to... • Be available to all oracle customers (no EE functionality) • Not needing any special system/sys access • Be supported by Oracle – no messing with apex objects or apex schema • Survive upgrades • Be easy to maintain, debug, change
Architecture What are the parts ? • Generate a table for every view we want to track • Generate a trigger on each of those tables • For every column that we want to track, log old/new value in case of change. • Merge the view data into our tables and we’re flying !
Implementation Naming conventions • Activities: Initialize data and Log incremental changes • Transactions: Row level changes (I/U/D) • Audit Logs: Column value changes
Implementation The work. Step 1: Create Objects • Create table <my_apex_view> as select * FROM <apex_view> were 1 = 2 • Challenges: • Which views ? APEX_DICTIONARY • Fails for APEX_APPLICATION_LISTS with ORA-1723 • Some Bugs in APEX_DICTIONARY • Solution: Create helper table CTA_VIEW_ATTRIBUTES
Implementation The work. Step 2: Create Objects • Create trigger on each table INS/UPD/DELETE for each row. Trigger calls procedure to store old/new values if there is a change (asktom). • Challenges: • Oh no ! PAGE_NAME seems to be everywhere ?? • Do I track all columns (even COMPONENT_SIGNATURE ?) • How do I uniquely define a row (some documented, some not documented, some not available and skipped) • Solution: Create helper table CTA_VIEW_EXCL_COLUMNS to store columns to exclude for table and child table (based on apex_dictionary hierarchy)
Implementation The work. Step 3: Initialize Data • Copy the current application view data into our newly created tables. • Disable triggers for this operation. • Merge statement (see later) on unique key from CTA_VIEW_ATTRIBUTES
Implementation The work. Step 4: Log Changes • Merge the current apex view data into CTA tables (Merge + Delete) • Challenges: • After a Log Changes operation, the data in our CTA tables is now identical what if more changes come up. • Solution: restore old version and Initialize Data • Better solution: parameter INCREMENT_VIEW_DATA. Use AUTONOMOUS TRANSACTION to store delta and roll back transaction.
Implementation Quirks, open issues and unexpected results • You learn how internals work and not everything is what it seems: • eg: do anything on IR and CT_APPLICATION_PAGE_IR_RPT gets updated • Eg: CT_APPLICATION_PAGES.PAGE_FUNCTION only set after builder is run • Control characters trigger a change (this is not logged as change)
Implementation I knew you were going to ask... • Can I copy from another app id ? • Can I get my hands on this ? • This is more than just a working prototype right ? And it is fully supported by Oracle ? • Apex 5 (Yes, if...) ? • Warning ! (hint... Security)