apex plsql report regions and apps that build themselves
DESCRIPTION
ApEx PLSQL Report Regions and Apps that Build Themselves. Bill Holtzman and Steve Schreck National Air Traffic Controllers Association. NATCA. National Air Traffic Controllers Association Federal Aviation Administration employees Mountains of regulations and business rules - PowerPoint PPT PresentationTRANSCRIPT
1
ApEx PLSQL Report Regions
and
Apps that Build Themselves
Bill Holtzman and Steve Schreck
National Air Traffic Controllers Association
22
NATCA
National Air Traffic Controllers Association• Federal Aviation Administration
employees• Mountains of regulations and business
rules• 400 US facilities• 15,000 members• 1000 Reps
33
Air Traffic Control Display
44
All US Flights
55
Major Apps
Grievance Tracking: GATS– PLSQL generated SQL
report regions
Survey Tool: Survey Junkie– App creates new
pages, items, etc.
6
Participate in the Demo
http://demo.natca.net
77
Grievance Tracking
88
Manual Column Link
select '<a href="' || apex_util.prepare_URL('f?p= &APP_ID.:8:' || :APP_SESSION || ':::8: P8_DUP_GRID,P8_RET_PAGE:' || g.grid || ',32') || '">' || g.natca || '</a><br /><span style="font-size:8pt">' || g.faanum || '</span>' "NATCA/FAA" from grievance g
target URL in blue – HTML link in red
99
Manual Link with Javascript
select '<a href= "javascript:myPopUp(''' || apex_util.prepare_URL('f?p=&APP_ID.:9:' || :APP_SESSION || '::::P9_GRID:' || g.GRID) || ''')">' || g.topic || '</a>' “Grievance Regarding” from grievance g
1010
Composite Data Column
selectdecode(g.status_id, 1, decode(g.date_sub_2, null, trunc(g.u_action_2) - trunc(sysdate) || ' ' ||casewhen (g.u_action_2 - sysdate) > 7 then '<img src = "#FLOW_IMAGES#greenN.gif">'when (g.u_action_2 - sysdate) > 3 then '<img src = "#FLOW_IMAGES#yellowN.gif">'when (g.u_action_2 - sysdate) > 0 then '<img src = "#FLOW_IMAGES#redN.gif">'else '<img src="#FLOW_IMAGES#past.gif">'end,to_char(g.date_sub_2, 'MM/DD/YY')), 'Closed') "DATE_SUB"from grievance g
1111
Sorting Issue
1212
WHERE Clauseswhere g.gr_status = 2and g.status_id = p.idand ((g.faanum like '%'||:P32_FAANUM||'%' and :P32_FAANUM is not null)
or :P32_FAANUM is null)and ((:P32_FACILITY_ID != 0 and g.facility_id = :P32_FACILITY_ID) or
(:P32_FACILITY_ID = 0 and (g.facility_id in (select id from gr_facility_lookup where region_id = (select y.region_id from gr_facility_lookup y, gr_emp z where upper(z.username) = :APP_USER and z.facility_id = y.id)) or g.facility_id = 3)))
and (g.status_id = 1 or g.close_date > sysdate - :P32_DAYS)and ((g.date_sub_2 is not null and :P32_NF = 1) or (g.date_sub_2 is null
and :P32_NF = 2) or (:P32_NF = 0))and g.status_id != 2and (:P32_REP is null or lower(g.rep) like '%' || lower(:P32_REP) || '%')and (:P32_NATCA is null or upper(:P32_NATCA) = g.natca)and (:P32_GRIEVANT is null or upper(g.grievant) like '%'||
upper(:P32_GRIEVANT)||'%')and (:P32_TOPIC is null or lower(g.topic) like '%' || lower(:P32_TOPIC) ||
'%')order by g.status_id, trunc(g.reply_by_2), trunc(g.date_sub_2) nulls last,
trunc(g.u_action_2) nulls last, trunc(g.date_rec_1) nulls last, trunc(g.date_sub_1) nulls last, substr(g.natca,4,3), g.natcasub
1313
Converting to PLSQL
declarep_sql varchar2(32767);beginp_sql := q'! select * from grievance where $P7_SHOW =
1 !';return replace(p_sql, '$', ':');end;
1414
Stripping WHERE Clauses
declarep_sql varchar2(32767);beginp_sql := q'! select g.grid, !';p_sql := p_sql || q'! '<a href="javascript$myPopUp(''f?p=&APP_ID.$9$' || $APP_SESSION || '$$$$P9_GRID$' || g.grid || ''')">' || g.topic || '</a>' || gr_groupid(g.grid) "Topic“ !';p_sql := p_sql || q'! from grievance g, gr_status_lookup p, gr_bu b where g.gr_status = 3 and g.status_id = p.id and g.bu_id = b.id (+) !';if :P35_FAANUM is not null thenp_sql := p_sql || q'! and lower(g.faanum) like '%' || lower($P35_FAANUM) || '%' !';end if;return replace(p_sql,'$',':');end;
No user text = no where clause!
1515
Complex Sorting w/PLSQLdeclarep_sql varchar2(32767);beginp_sql := q'! select g.GRID, !';p_sql := p_sql || q'! '<a href="javascript$myPopUp(''f?p=&APP_ID.$9$' || $APP_SESSION || '$$$$P9_GRID$' || g.GRID || ''')" &F168_PRINT.>' || g.topic || '</a>' || gr_groupid(g.grid) "Topic" !';p_sql := p_sql || q'! from grievance g, gr_status_lookup p, gr_bu b where g.gr_status = 3 and g.status_id = p.id and g.bu_id = b.id (+) !';casewhen :P35_SORT = 1 then p_sql := p_sql || q'! order by trunc(g.reply_by_3), trunc(g.date_sub_3) nulls last !';when :P35_SORT = 2 then p_sql := p_sql || q'! order by trunc(g.date_sub_3), trunc(g.u_action_3) nulls last !';else null;end case;return replace(p_sql,'$',':');end;
1616
Result
17
Database-driven Javascript
declarep_java varchar2(4000);cursor c1 is select bu_id, bplate from gr_bu;beginp_java := 'function insertBP(p_region_id) {var p_bu_id = document.getElementById("P8_BU_ID").value;';for a1 in c1 loopp_java := p_java || chr(10) || 'if (p_bu_id == ' || a1.bu_id || ')' || chr(10) || 'document.getElementById("P8_BPLATE").value = "' || a1.bplate || '";';end loop;p_java := p_java || chr(10) || '}';:F168_BPLATE_JAVA := p_java;end;
1818
Apps that Build Themselves
1919
Subscription Tools
2020
In-house Advantages
• Direct integration with internal database
• Information stays on your server• App can be customized for future
needs• No reliance on outside support
2121
Concept Development
• Individual survey construction?• Substitute user-supplied questions
into existing item labels and user-supplied answers into Select Lists?
2222
Export File Components
wwv_flow_api.create_page_item( p_id =>7422425059996976 + wwv_flow_api.g_id_offset, p_flow_id => wwv_flow.g_flow_id, p_flow_step_id => 1, p_name =>'P1_DEMO', p_display_as => 'RADIOGROUP', p_item_sequence => 10, p_item_plug_id => 7401108705976868+wwv_flow_api.g_id_offset, p_begin_on_new_line => 'YES', p_begin_on_new_field => 'YES', p_colspan => 1, p_rowspan => 1, -- etc.) wwv_flow_id.next_val
2323
The Question
Can we use ApEx’ own export code to create ApEx objects from within an app?
2424
Concept
Demo
25
Online Demo
26
Caveats
• Use of wwv_flow_api not specifically supported by Oracle
• Do not over-write your app in PROD!
• The app cannot in some cases be imported successfully.
28