Professional Documents
Culture Documents
Advanced Application Express: Tips and Techniques
Advanced Application Express: Tips and Techniques
Advanced Application Express: Tips and Techniques
www.tusc.com/briefing
By Bradley D. Brown
http://bradleydbrown.blogspot.com
Chairman and Chief Architect, TUSC
Abstract
Oracle Application Express is a powerful
and comprehensive tool. Numerous
advanced tips and techniques will be
covered in this presentation. These
topics include: pop-up windows, complex
searches, document management,
indexing and searching, tool tip or hints,
email links, page 0, help text, background
jobs, add to my calendar feature, saving
contacts, sending mass emails, and
more.
Topics
HTML
Favorite Icon
Pop-ups & pass-backs
Tool tips
Anchors
Apex
Page 0
Help text / page
Custom login page
Scrolling text
Document Management
Outlook Integration
Email
PL/SQL
Complex searches
Function-based queries
Background jobs
JavaScript
Setting focus
AJAX
Netflix Flyups
Google Maps
HTML Tips
Favorite Icon
$ORACLE_HOME\Apache\Apache\htdocs
In Page template
Pop-up windows
Pop-up Window
Target=_blank in Link
Attributes
Anchors
Anchors can provide direct links to places on a page
<a name="Top">
This way you can place a return to top link anywhere on the
page
Page 0
Help text
Page level help text
Highlight Current
Key Elements
Hidden Items to
implement details
Custom Templates to
highlight current row
Variation on
alternating color
report template
PL/SQL expression
condition for
selected row
Custom Template
http://forums.oracle.com/forums/thread.jsp?forum=137&thread
=220034
Document management,
indexing and searching
Documents will be stored in Oracle Application
Express schema
See Sample Application for great code examples
Create a table to store the link to the documents
Link is to p?n=document_number
select DESCRIPTION, decode(document, null, '<a href="f?p=' ||
:app_id || ':11:::::p11_person_id,p11_document_id:' ||
person_id || ',' || document_id || '">Upload Supporting
Document</a>', '<a href="p?n=' || document || '">Download
Document</a>') document
from PERSON_DOCUMENT
where person_id = :p1_id
If you
Easier to export an
application (and
data) otherwise, its
in Apex schema
Create placeholder
CREATE TABLE
TEMP_RESUMES
(NAME VARCHAR2(90),
BLOB_CONTENT BLOB)
Dir /b >resume.ctl
Add SQL*Loader
text above list
Sqlldr user/pass
control=docs.ctl
load data
infile *
into table resumes
fields terminated by ',
(file_name char(50),
blob_content lobfile(file_name)
terminated by eof)
BEGINDATA
a.doc
b.doc
Loading Documents
Need a process to
move document after
upload
See
http://download.oracl
e.com/docs/cd/B324
72_01/doc/appdev.3
00/b32469/up_dn_fil
es.htm
INSERT INTO
resumes(id,flow_id,name,filename,mime_type
,doc_size,dad_charset,created_by,created_o
n,updated_by,updated_on,last_updated,cont
ent_type,blob_content,description) SELECT
id,flow_id,name,filename,mime_type,doc_size
,dad_charset,created_by,created_on,update
d_by,updated_on,last_updated,content_type,
blob_content,:P20_DESCRIPTION FROM
APEX_APPLICATION_FILES WHERE name =
:P1_FILE_NAME;
DELETE from APEX_APPLICATION_FILES
WHERE name = :P1_FILE_NAME;
The Results
Add contact
Email Links
Mass Email
Campaigns
Reminders
Workflow
Email links
Select statement
Link
htp.print('ORGANIZER:MAILTO:br
ad@tusc.com');
owa_util.MIME_HEADER('text/cal
endar; method=request');
htp.print('DTSTART;TZNAME=MST:
' ||
to_char(nvl(to_date(v('P12_
expires_ON'),'mm/dd/yyyy'),
l_expires_on), 'yyyymmdd')
|| 'T080000');
htp.print('DESCRIPTION:Reminde
r for account expiring');
htp.print('VERSION:2.0');
htp.print('END:VALARM');
htp.print('METHOD:PUBLISH');
htp.print('END:VEVENT');
htp.print('BEGIN:VEVENT');
htp.print('END:VCALENDAR');
end;
Similar to ICS
Branch to a PL/SQL page
Mime-type is key
Declare
cursor user_cur is
htp.print('BEGIN:VCARD');
htp.print('VERSION:3.0');
from
demo_users
htp.print('N:' ||
user_rec.user_name || ';;');
where
user_id = :p14_user_id;
htp.print('ADR;HOME:;;');
htp.print('EMAIL;PREF;INTERNET:' ||
user_rec.email_address);
Begin
owa_util.MIME_HEADER('text/xvcard; method=request');
htp.print('REV:20050707T234724');
htp.print('END:VCARD');
end loop;
end;
PL/SQL tips
Complex searches
Indexes on columns
Use like :p1_search || %
Dont use like % || :p1_search || % or instr
Use separate pages / queries / regions for each field queried
Can use Oracle Text (i.e. contains)
Function
Table and column data types
View based on casted function
The Function
RSVP_FUNCTION
CREATE OR REPLACE FUNCTION rsvp_function
(in_event_no number)
rsvp
where
event_no = in_event_no;
RETURN rsvp_table
PIPELINED IS
out_rec
RSVP_COLUMNS :=
RSVP_COLUMNS(NULL,NULL,NULL,NULL,NUL
L);
TableSet
RSVP_TABLE;
cursor min_max_cur is
from
rsvp
where
event_no = in_event_no
and
total
number := 0;
max(trunc(rsvp_date)) max_date,
max(trunc(rsvp_date))min(trunc(rsvp_date)) days
from
rsvp
where
event_no = in_event_no;
cursor count_invitees_cur is
RSVP_FUNCTION
BEGIN
-- Figure out the total count of
invited people
for count_invitees_rec in
count_invitees_cur loop
total :=
count_invitees_rec.count;
end loop;
for count_as_of_rec in
count_as_of_cur(out_rec.rsvp_date)
loop
out_rec.y
count_as_of_rec.y;
:=
out_rec.n
count_as_of_rec.n;
:=
out_rec.w
total - count_as_of_rec.y count_as_of_rec.n;
:=
end loop;
for min_max_rec in min_max_cur loop
FOR i IN 1 .. min_max_rec.days+1
LOOP
PIPE ROW(out_rec);
END LOOP;
out_rec.event_no
:= in_event_no;
out_rec.rsvp_date :=
min_max_rec.min_date + i - 1;
END LOOP;
RETURN;
END;
Columns
CREATE OR REPLACE
TYPE rsvp_Columns AS OBJECT
( event_no number,
rsvp_date date,
y number,
n number,
w number);
Table
CREATE OR REPLACE
TYPE RSVP_Table AS TABLE OF YPO.RSVP_COLUMNS
The Results
Apex_plssql_job
Apex_collection
Apex_Ldap
Apex_Mail
Apex_Util
Background jobs
UPDATE_JOB_STATUS
Updates the status of the currently running job. Most effective when called
from the submitted PL/SQL.
TIME_ELAPSED
Determines how much time has elapsed since the job was submitted.
JOBS_ARE_ENABLED
PURGE_PROCESS
JavaScript
JavaScript provides clientside power
AJAX
Rest
Excellent examples
http://apex.oracle.com/pls/otn/f?p
=11933
Using AJAX
Asynchronous Java Script and XML
Using AJAX
Select a value
Populates Job
Select a department
Populates select list
On Demand
returns value or XML document
Netflix Flyups
Netflix uses AJAX to
retrieve its flyups.
For a great thread on how
to implement this, see
http://forums.oracle.com/fo
rums/thread.jspa?threadID
=318874&tstart=0
Easy integration
http://www.google.com/apis/maps/documentation/
Summary
800-755-TUSC
sales@tusc.com
303-985-2213
brad@tusc.com
http://www.tusc.com
Register for our newsletter
Questions?
Wireless
JavaMail
UltraSearch
Search Engines
iFS
JavaScript
Security
Special Thanks
Database
SQL
Applications
PL/SQL
New Features
Forms, Reports
Security
Designer
Migrations
Team Management
Discoverer & BI
Uncommon Leaders
Built-in Packages
Workflow
DBA topics
Copyright Information
Neither TUSC nor the author guarantee this document to
be error-free. Please provide comments/questions to
bradley_d_brown@tusc.com.
TUSC 2007. This document cannot be reproduced
without expressed written consent from an officer of
TUSC.