Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2008 the award-winning graphical data mapping tool from the creator
of XMLSpy
Visual Studio
2005
& 2008
Connecting data to Web services
Auto-generation of XSLT 1.0 and 2.0, XQuery, Java,
C#, or C++ for royalty-free use
Drag & drop Web services creation
Extensible function library for fltering / processing data
Visual function builder for custom functions
Instant data conversion & output window
Flat
files
WS EDI
XML
XML Databases EDI Flat Files Web Services
M F O l M i dd 1 3/4/2008 10 9 08 AM
omag0508p014.indd 1 3/18/08 10:41:58 PM
a t O r a c l e RESOURCES
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 1 5
Whats New at Oracle
The latest podcasts, courses, and offers
WEBCAST
Upgrading to Oracle Fusion Applications:
Planning Ahead
oracle.com/pls/ebn/live_viewer.main?p_
shows_id=6119672
Cliff Godwin, senior vice president of appli-
cations development, Oracle, discusses
the importance of upgrading to the latest
Applications Unlimited releases and the
evolutionary path to Oracle Applications
built on Oracle Fusion Middleware.
PRODUCT DEMOS
Oracle JHeadstart Demos Available
otn.oracle.com/products/jheadstart
Oracle JHeadstart is an extension to
Oracle JDeveloper that boosts devel-
oper productivity when building Oracle
Application Development Framework
(Oracle ADF) applications. It is based
on Oracle Consultings best practices
on various large Oracle ADF projects.
New demos are available for download
that show you how to add multilanguage
support, fine-grained security, and flex-
fields to your Oracle ADF application;
upgrade your Oracle JHeadstart /Oracle
ADF 10g application to Oracle ADF 11g; and
migrate your Oracle Forms application to
an Oracle ADF application.
ORACLE UNIVERSITY
Hyperion Financial Management 9.3.1: Create
and Manage Applications
oracle.com/education
(Search keyword: Hyperion Financial
Management 9.3.1)
This five-day course provides instruction
on creating and managing applications in
Hyperion Financial Management. Students
learn to create an application, enter data,
and adjust and view data using data grids
and data forms. They also learn to enter and
process journals and intercompany data,
load rules, calculate and consolidate data,
manage the review and approval process of
financial data, and apply system security to
Hyperion Financial Management data.
Hyperion Planning 9.3.1: Create and Manage
Applications
oracle.com/education
(Search keyword: Hyperion Planning 9.3.1)
This five-day course provides instruction
for creating and managing applications
using Hyperion Planning. Students learn
to create applications, add dimensions
and members, import members, load data,
set up security, create data forms, set up
task lists, set up calculations, and move a
plan through the planning cycle. Students
also learn to access data offline and
analyze plan data.
PODCASTS
Greening Your Supply Chain
oracle.com/profit/audiocasts.html
Rich Kroes, product strategy director for
Oracle supply chain management, spent
2007 raising awareness about the economic
and social benefits of a greener supply
chain. He talks about how Oracles exper-
tise with data and operational efficiency
make the companys solutions perfect for
going green.
Hosting Government Systems with Oracle
On Demand
oracle.com/magcasts
Richard Cirigliano, Oracle vice president, On
Demand for the federal government prac-
tice, talks about how hosted software has
fundamentally changed the IT strategy of
the U.S. federal government.
Whats Fueling the Increased Customer
Adoption of Identity Management and Driving
Oracles Security Product Strategy?
oracle.com/products/middleware/
ofmradio.html
Hasan Rizvi, vice president of identity
management products, Oracle, talks about
trends driving increased customer adoption
of identity management and whats driving
Oracles identity management product strat-
egy, including the most recent acquisitions
and the product road map.
SOA for the Real World
oracle.com/techcasts
Demed LHer, senior principal product
manager from the Oracle SOA Suite team,
talks about whats unique in the suite and
why support for service component archi-
tecture and complex event processing tech-
nologies is so important.
Oracle Real Application Testing
oracle.com/database/podcasts.html
David Mitchell, senior vice president of
research at Ovum, discusses the key chal-
lenges facing IT when it comes to inad-
equate testing of production applications
following change implementation and how
Oracle Real Application Testing stacks up
For Oracle product information, call the number for
your region:
Country Phone Number
U.S. and Canada.....................................1.800.367.8674
Australia ....................................................1800.735.467
Austria.......................................................0800.29.7626
Belgium........................................................0800.73280
Brazil .........................................................0800.901.985
China.........................................................800.810.0161
Denmark.........................................................8088.1068
Finland ......................................................0800.113.573
France .......................................................0800.905.805
Germany.................................................0800.1.810.111
Greece.................................................00800.353.12020
Hong Kong......................................................3002.1246
India ..........................................................1600.44.6725
Indonesia...........................................001.800.1.672.253
Ireland........................................................1850.672253
Italy ..............................................................8008.74720
Japan ........................................................0120.155.096
Malaysia....................................................1800.80.1837
Mexico...................................................01800.221.7321
The Netherlands .............................................0800.0827
New Zealand .............................................0508.555.215
Norway...........................................................800.14411
Philippines........................................................811.5831
Portugal .......................................................800.853.021
Singapore................................................1800.6722.531
South Africa...............................................0800.994.225
South Korea...............................................080.2194.114
Spain............................................................900.952900
Sweden ........................................................020.798798
Switzerland................................................0800.55.2574
Taiwan.......................................................0800.672.253
Thailand ..............................................001800.441.0545
Turkey .................................................00800.353.90014
U.K. .........................................................0870.5.332200
MJ08_Resources.indd 15 3/12/08 1:58:00 PM
1 6 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
RESOURCES
ORACLE E-MAIL SUBSCRIPTIONS
Stay Informed
oracle.com/goto/signup
Oracle newsletters and e-mail announce-
ments are the best way to stay informed
about new Oracle products and features,
trends, and issues affecting how you use IT
in your business; upcoming events you dont
want to miss; and special offers. Subscribe
to your choice of 16 targeted newsletters
and get news and original content on a
regular basis. Or sign up for Oracle news
and product announcements, and get infor-
mation as it becomes available.
RESOURCE KITS
Get SOA Expertise On Demand
oracle.com/goto/soaoffer
Register to access the SOA Leadership
Roundtable Webcast, where leading com-
panies and industry experts share their
experiences in designing and implement-
ing SOA solutions. Find out why these
organizations chose an SOA approach,
how they secured management approval
and addressed challenges, and lessons
learned during implementation. Other SOA
resources, including a free SOA assess-
ment, are also available.
Get Started with Oracle on Windows DVD
oracle.com/goto/powertogrow
Learn how Oracle gives you the power to
grow in a Windows environment by provid-
ing a scalable, easy-to-use platform for
running your business at a price you can
afford. Request your free copy of this DVD,
which contains Oracle Database 11g soft-
ware, white papers, and tutorials.
against traditional methods of testing in
database environments.
Growing Your Business with Oracle Database
oracle.com/database/podcasts.html
Oracle customer Tom Clark, CIO of
Property Condition Assessments, dis-
cusses how Oracle Database Standard
Edition One addresses the needs of
midsize companies like his by providing a
scalable, affordable, and secure platform
for growing your business.
Solving Business Challenges with Oracle
Application Express
oracle.com/database/podcasts.html
Chris Thomson, solutions director at Indigo
Tide, a consulting organization with a focus
on Oracle technologies, discusses how he
uses Oracle Application Express to develop
fast, secure, and scalable Web applications
that automate workflow for his clients.
Using SecureFiles in Oracle Database 11g
oracle.com/database/podcasts.html
Tim Frazier, senior technical architect
at National Ignition Facility, discusses
how his company is using the Oracle
SecureFiles feature in Oracle Database
11g on a large scale to help harness clean,
efficient energy sources.
Why Oracle Customers Should Adopt SOA-
based Integration Today
oracle.com/appcasts
Nadia Bendjedou, director of product strat-
egy, Oracle, discusses service-oriented
architecture (SOA)based integration and
its role as the backbone for Oracles next
generation of applications.
Oracle Real Application Clusters on Windows
oracle.com/database/podcasts.html
Sachin Kothari, manager of corporate appli-
cations and systems integration at Solutia,
discusses how the global chemical manu-
facturing company improved its application
performance, scalability, and reliability by
deploying Oracle Real Application Clusters
on Windows.
Data Integration: Missing Piece for a
Successful Service-Oriented Architecture
oracle.com/products/middleware/
ofmradio.html
Miranda Nash, senior director of devel-
opment, Oracle Fusion Middleware,
describes Oracles data integration strat-
egy and why data integration is key to a
successful SOA.
Fusion Development Experience and Oracles
Next-Generation Applications
oracle.com/products/middleware/
ofmradio.html
Ted Farrell, chief architect for Oracle
Fusion Middleware, discusses the Oracle
Fusion Middleware development experi-
ence and its benefits for Oracles next-
generation applications, plus the latest on
Enterprise 2.0 technologies.
Applications Unlimited and Siebel 8.0
oracle.com/appcasts
Scott Nash, vice president, Oracles Siebel
product management, discusses the
success of the Siebel 8.0 release, cus-
tomer momentum, how Oracle continues
to invest in the Siebel product line, and
whats new for Siebel and customer rela-
tionship management (CRM).
What Are Social CRM Applications?
oracle.com/applications/podcast-
fusion.html
Anthony Lye, senior vice president of CRM,
Oracle, discusses how Oracles social CRM
applications combine powerful enterprise
applications and the latest in social net-
working with Web 2.0 technology to improve
end-user productivity.
When you think about the impact that companies have on
the environment, it really starts at the beginning of their
value chains with how a companys products are sourced,
produced, fulfilled, serviced, and ultimately how they are
disposed of.
Rich Kroes, Product Strategy Director, Oracle Supply Chain Management, in the Greening Your
Supply Chain podcast (oracle.com/profit/audiocasts.html)
OVER
HEARD
Oracle Blog Center
oracle.com/blogs
Oracle Consulting
oracle.com/consulting
Oracle events and Webcasts
oracle.com/events
Oracle Podcast Center
oracle.com/podcasts
OracleMetaLink
metalink.oracle.com
Oracle Newsletters
oracle.com/newsletters
Oracle Support
oracle.com/support
Oracle University
oracle.com/education
MJ08_Resources.indd 16 3/12/08 1:58:12 PM
a t O r a c l e OTN BULLETIN
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 1 7
BY JUSTI N KESTELYN
Embracing Web 2.0
OTN lights the way at Oracles marketing 2.0 summit.
s a community, Oracle Technology
Network (OTN) members have
been interacting informally for
nearly a decade now. Were used
to anything-goes discussions; building
on each others work; and learning from
informal, user-created content. Except for
a few commonsense rules of the road,
OTN is a relatively open environment.
This was the model set before a group
of leaders from across Oracles vast mar-
keting organization, which met in January
2008 to participate in a competition-
based marketing 2.0 summit. The event
was not about Web 2.0 technology per se,
but rather about the impact of collabora-
tive community participation on how we
work together internally as well as with
customers and partners.
The summit implemented design
principles that, in my opinion, set the
standard for such meetings, within
Oracle or elsewhere. Most important
among them was a commitment to use
Web 2.0 tools. For example, all com-
munications about meeting logistics
occurred via a private Facebook group,
and the summits DNA was made of
open space memes. Attendees were
expected to have completed homework
assignments, which included hands-
on use of standard-issue tools such
as Twitter and Google Reader. And all
meeting notes were recorded via wiki.
The summit was a real mind opener.
Im confident that Oracles global market-
ing organization is now on the same page
about things such as the value of trading
control for influence, promoting transpar-
ency, and working with the rest of the
Oracle ecosystem collaboratively in ways
that do not necessarily involve technol-
ogy. This is good news for developers,
who thrive on relationship networks as
well as community-generated content.
With this event, Oracle has headed
down the road toward embracing these
concepts on a wider scale. OTN members
can be proud for leading the way.
Watch video from the marketing
2.0 summit, and read more about it, at
blogs.oracle.com/otn/2008/02/01#a1217.
OTN DEVELOPER DAY: FOCUS ON THE ORACLE
FUSION DEVELOPER
In 2007, OTN Developer Day work-
shops were convened in cities all across
the globe. In 2008 and beyond, youll
see even more of them, in even more
countries, and on even more topics.
Although OTN Developer Day
will continue to be offered globally to
database application developers who
want to learn how to use tools such as
Oracle Application Express, Oracle SQL
Developer, and Oracle Developer Tools for
Visual Studio, going forward the primary
focus will be on serving the newly emerg-
ing Oracle Fusion developer role. If you
are an Oracle Forms developer investi-
gating a transition toward Java Platform,
Enterprise Edition, and service-oriented
architecture; a Java developer exploring
the principles of rich internet applica-
tions; or an application developer seeking
to synergize business processes across
different packaged applications, OTN
Developer Day is an excellent platform
from which to dive into those topics.
With a curriculum recently updated for
use with Oracle Fusion Middleware 11g
Technical Previews, these free workshops
are even more relevant for developers
who dont want to be left behind.
See the OTN Developer Day sched-
ule for North America and register at
otn.oracle.com/events/otn-developer-day.
IN THE MIX
Oracle Mix started off as a charming
diversion, but now its on its way to
becoming the epicenter of the rich and
diverse Oracle community.
Originally a proof of concept created
by Oracle AppsLab, Oracles internal
think tank, Oracle Mix is now the de
facto social network for Oracle custom-
ers and partners. Thanks to an appeal-
ing and adaptable set of features, Oracle
Mix is a framework in which a broad
range of affinity groups can mature.
Groups include those dedicated to
Oracles PeopleSoft Enterprise Portal;
the Undutchables (users from the
Netherlands); Oracle E-Business Suite
DBAs; and of course, OTN members. In
a sense, Oracle Mix is now the ultimate
example of Oracle hosting and facilitat-
ing the ongoing conversation. Join in at
mix.oracle.com. O
Justin Kestelyn (justin.kestelyn@oracle.com) is senior
director, Oracle Technology Network and developer
programs, as well as OTN editor in chief.
OTN home
otn.oracle.com
OTN Headlines
otn.oracle.com/pub/news
Free software downloads
otn.oracle.com/software
Documentation
otn.oracle.com/documentation
Technology Centers
otn.oracle.com/tech
Podcasts
otn.oracle.com/techcasts
Technical articles
otn.oracle.com/pub/articles
Blogs
blogs.oracle.com
Discussion forums
forums.oracle.com
Developer Events Calendar
otn.oracle.com/events
Oracle ACE Program
otn.oracle.com/goto/oracle-ace
MJ08_OTN.indd 17 3/12/08 12:53:53 PM
a t O r a c l e BRIEFS
?
KNOW D I D Y O U
1 8 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
?
KNOW D I D Y O U
ORACLE SECURE BACKUP 10.2 AVAILABLE
O
racle is now shipping Oracle Secure
Backup 10.2, a high-performance tape
backup for Oracle databases and network-
attached storage (NAS) file systems.
Oracle Secure Backup is a complete enter-
prise solution for centralized tape backup
management with advanced features such
as encryption, vaulting, and dynamic
drive sharing. Customers can achieve
high-quality, low-cost data protection for
their entire IT environment with Oracle
Secure Backups security policies that
safeguard data stored on tape and control
access to backup systems and data.
This new release provides policy-
based encryption at the domain, host,
backup, or tape level. Oracle Secure
Backup 10.2 provides automated man-
agement of all encryption keys associated
with tape backups. Encryption keys are
centrally stored on the Oracle Secure
Backup Administrative Server, which
manages decryption during restoration.
Oracle Secure Backup 10.2 auto-
mates tape management throughout its
lifecycle, from creation to expiration to
reuse. Existing tape storage pool concepts
have been extended to include policy-
based management for tape vaulting,
duplication, and migration from virtual
tape library to physical tape. In addition,
Oracle Secure Backup automates tape
management according to user-defined
policies, which may include duplicating
tapes that leverage the same or differ-
ent retention and vaulting schedules as
original tapes and scheduling rotation of
tapes between multiple locations.
Performance is the No. 1 concern of
most customers focused on backup and
recovery, says Juan Loaiza, senior vice
president, systems technology, Oracle.
Customers will be able to achieve up to
40 percent faster Oracle Database backup
to tape using Oracle Secure Backup 10.2.
ORACLE DATABASE VAULT CERTIFIED FOR
ORACLE E-BUSINESS SUITE
O
racle has certified Oracle Database
Vault for use with the Oracle
E-Business Suite, which enables custom-
ers to better protect sensitive applica-
tion data from unauthorized access by
usersincluding privileged users who
are misusing their privileges. Oracle
Database Vault is an advanced database
security product designed to enforce
when, where, how, and by whom data
can be accessed.
Many Oracle E-Business Suite
applications, including Oracle Human
Capital Management, Oracle Financial
Management, Oracle Supply Chain
Management, and Oracle Customer
Relationship Management, contain
personal identification information,
social security numbers, or credit card
numbers. Regulations such as Sarbanes-
Oxley, the Health Insurance Portability
and Accountability Act, Basel II, and
Payment Card Industry Data Security
Standards require companies to consider
separation of duty and strong controls
on access to sensitive information. The
certification of Oracle Database Vault for
use with Oracle E-Business Suite enables
customers to better address their security
and regulatory challenges.
Oracle Database Vault transparently
defends against unauthorized access to
application data as well as intentional or
accidental harmful database changes by
any users, even DBAs, by considering
factors such as time of day, authentica-
tion, and application. It can also be used
to enforce separation of duties within
the database. For example, Oracle
Database Vault can block a DBAs access
to sensitive application data, while per-
mitting the DBA to perform day-to-day
operations such as database backup and
recovery, tuning, and replication. With
Oracle Database Vault, customers can
consolidate application databases and
enforce strong boundaries and policies
around access to that data.
Oracle Database Vault monitors
activity inside the database and enforces
real-time preventive controls, says Vipin
Samar, vice president of database security,
Oracle. Organizations can now protect
sensitive Oracle E-Business Suite applica-
tion data at the sourcethe database.
SECURITY SKILLS MOST NEEDED FOR IT
A telephone and online survey of more than
3,500 IT professionals in North America,
Europe, and Asia showed that security-
related skills are considered most important
to todays IT organizations. In countries with
established IT industries, including Australia,
Canada, France, Germany, Italy, Japan, the
Netherlands, the U.K., and the United States,
73 percent of survey respondents said security
was most important, but just 57 percent said
that IT employees were proficient in these
areas. The gap was wider in countries with
emerging IT industries, including China, India,
Poland, Russia, and South Africa, where 76
percent said security skills were important but
only 57 percent had those skills.
Source: CompTIA
www.comptia.org/pressroom/get_
pr.aspx?prid=1317
SERVER VIRTUALIZATION IMPORTANT, BUT
HARD TO MEASURE RETURN
More than half of large enterprises
worldwide54 percentthink managing their
virtual server environment is a critical or high
IT priority, but just 45 percent think theyre
doing an effective job of it. In a survey of 300
CIOs and IT executives in the U.S., Europe, the
Middle East, Africa, and Asia Pacific working
for companies with more than US$250 million
in annual revenue, 56 percent of respondents
said they are using multiple platforms or
vendors for server virtualization management,
while 35 percent have standardized on
a single vendor. Just 28 percent of CIOs
responding have a method in place to measure
virtualization return on investment.
Source: CA
www.ca.com/about/virtual_survey
EVALUATION SOFTWARE POPULAR, USEFUL
95 percent of software developers download
evaluation copies of software from vendors,
according to an online survey of 386 IT
developers. A full 70 percent evaluate what
they download, and 80 percent of evaluators
end up buying at least some of the software.
Source: Developer Marketing Patterns 2008,
Evans Data Corp.
www.evansdata.com/reports/viewRelease
.php?reportID=10
?
KNOW D I D Y O U
MJ08_BRIEFS.indd 18 3/12/08 11:55:15 AM
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 1 9
ORACLES JD EDWARDS ENTERPRISEONE
TOOLS 8.97 RELEASED
O
racles JD Edwards EnterpriseOne
Tools 8.97 is now generally avail-
able. This release provides streamlined
system management, faster performance
for client browsers, and improved report-
ing based on XML standards, to enable
JD Edwards EnterpriseOne customers to
achieve a lower total cost of ownership.
It also provides an open platform for
customers to choose hardware, operat-
ing systems, and database technologies
based on their IT strategies and business
requirements. JD Edwards EnterpriseOne
Tools 8.97 supports Oracle Enterprise
Linux and Oracle Fusion Middleware.
JD Edwards EnterpriseOne Tools
8.97 continues the evolution of JD
Edwards EnterpriseOne toward a
service-oriented architecture (SOA) and
provides customers with expanded func-
tionality, performance, and usability.
Our customers are under constant
pressure to achieve substantial pro-
ductivity gains with fewer resources.
Through an evolving and more com-
prehensive technology platform, we are
delivering a better ownership experi-
ence to our customers at a lower cost,
says Lyle Ekdahl, Oracle vice presi-
dent of product strategy. JD Edwards
EnterpriseOne Tools 8.97 also contin-
ues our delivery on the Applications
Unlimited commitment and allows
customers to take advantage of the
latest technology, in many cases without
having to upgrade their applications.
One of the new features in JD
Edwards EnterpriseOne Tools 8.97
is server manager, a centralized Web
console for the monitoring and manage-
ment of all JD Edwards EnterpriseOne
server components. Other enhancements
include simplified menu navigation, use
of browser tabs, easier import/export
of data in JD Edwards EnterpriseOne
application forms, and support for the
Firefox browser.
Thanks to the latest tools release, JD
Edwards EnterpriseOne applications
can operate in an SOA natively, without
dependency on third-party products.
Design tools, wizards, and reference
implementations are provided to help
customers and partners leverage these
new integration capabilities.
JD Edwards EnterpriseOne Tools 8.97
also delivers improved embedded report-
ing with Oracle Business Intelligence
Publisher. Users can launch a complete
run-publish-distribute cycle from a
single user interaction, output multiple
objects such as invoices from a single
batch of data, and produce reports in
multiple formats including Adobe PDF,
HTML, RTF, Microsoft Excel, Microsoft
PowerPoint, XML, and eText.
ORACLE UNVEILS NEW ORACLE IDENTITY
MANAGER 10g RELEASE
A
new release of Oracle Identity
Manager, a key component of the
Oracle Identity Management 10g Release
3 suite of products, is now available. It
addresses the growing concerns orga-
nizations have regarding compliance
and the time it takes to complete an
audit. A component of Oracle Fusion
Middleware, Oracle Identity Manager
is a user-provisioning and administra-
tion solution that enables organizations
to automate the process of adding,
updating, and deleting user accounts
from applications and directories. It
improves regulatory compliance by
providing granular reports that indicate
exactly who has access to specific data,
resources, and information.
The new release features enhanced
attestation capabilities to automate the
ongoing certification of access privileges
to meet compliance requirements. It also
offers 19 new compliance and opera-
tional report templates that help organi-
zations streamline the audit process.
In addition, a graphic workflow
designer simplifies the creation and
maintenance of provisioning and
approval workflows; an inbound
gateway based on the Web Services
Service Provisioning Markup Language
(WS-SPML) 2.0 standard supports
rapid integration across heterogeneous
environments; and updated connector
wizards ease the creation of new connec-
tors and streamline integration.
The new release of Oracle Identity
Manager further delivers on our commit-
ment to provide customers provisioning
software that helps them more efficiently
meet compliance requirements while
improving security and the overall user
experience, says Hasan Rizvi, vice presi-
dent, identity management and security
products, Oracle. With this release, orga-
nizations can more rapidly experience
the benefits identity provisioning delivers
across their diverse IT environments.
ORACLE ACQUIRES CAPTOVATION
O
racle has agreed to acquire
Captovation, a leading provider of
document capture solutions that stream-
line the process of capturing mission-
critical content for access from within
business applications and processes.
Captovations software will be part of
Oracle Enterprise Content Management,
an Oracle Fusion Middleware com-
ponent that provides comprehensive
capabilities for managing dynamic,
transactional, and historical content.
By adding document capture to
Oracles leading content management,
process automation, and back-office
applications, Oracle will be the only
vendor that can provide customers with
a fully integrated solution for automat-
ing back-office operations, says Thomas
Kurian, senior vice president, Oracle
Server Technologies. O
Oracle Secure Backup
otn.oracle.com/products/secure-backup
Oracle Database Vault
oracle.com/database/database-vault.html
Oracles JD Edwards EnterpriseOne
Tools 8.97
oracle.com/applications/enterpriseone-tools-8-9-
7-data-sheet.pdf
Oracle Identity Manager
oracle.com/products/middleware/identity-
management/identity-manager.html
Oracle and Captovation
oracle.com/captovation
MJ08_BRIEFS.indd 19 3/12/08 11:55:33 AM
2
0
0
8
E
m
b
a
r
c
a
d
e
r
o
T
e
c
h
n
o
l
o
g
i
e
s
,
I
n
c
.
A
l
l
r
i
g
h
t
s
r
e
s
e
r
v
e
d
.
.
Provide a forum for sharing
knowledge and news from all
souroes with other 0Pu0
members.
Lnoourage broad use of the
produot through dialogue with
prospeotive oustomers.
Aohieve maximum business value
from our investment in 0raole
produots.
Register today at: www.ohug.org.
Mention this ad when registering
and save 10. Aooess Code:
0RACLLMA0
Join us!
Membership is free.
Oracle Human Capital Management User Group
Cedar Hill, TX 75106-1412
Why attend?
MJ08_FRAMEWORKS.indd 46 3/17/08 12:35:29 PM
BY DAVI D PEAKE
d e v e l o p e r BROWSER-BASED
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 4 7
The Power of Two
Use Oracle SQL Developer to aid Oracle Application Express development.
racle Application Express and
Oracle SQL Developer are
no-cost tools that both work
with Oracle Database versions
9.2 and above. Not only can Oracle
SQL Developer help you develop data-
base applications but it also lets you
browse, export, import, deploy, and
remotely debug your Oracle Application
Express applications.
This column introduces the ways
Oracle SQL Developer and Oracle
Application Express work together to
aid your development efforts. Well
see how to browse Oracle Application
Express information from within Oracle
SQL Developer. Then well walk through
an example of remotely debugging a
browser-based applications PL/SQL
code from Oracle SQL Developer.
OVERVIEW
Using Oracle SQL Developer in con-
junction with Oracle Application
Express, you can browse across mul-
tiple applications and pages and drill
down to specifics quickly. For example,
in Oracle Application Express, you
need two browsers to view the code
for two lists of values (LOVs) in two
applications simultaneously. In Oracle
SQL Developer, this task is as simple
as expanding both applications in
Connections Navigator. Oracle SQL
Developer also provides several very
useful and detailed reportsabout
applications, pages, schemas, and
workspacesspecifically for Oracle
Application Express (under Data
Dictionary Reports).
Oracle SQL Developer lets you
export, import, and deploy applications
across multiple workspaces, instances,
and databases. Right-clicking the appli-
cation name invokes a context menu
that lets you move the application and
its supporting objects from one work-
space to another. This capability is espe-
cially useful for deploying applications
from your development environment to
testing or production.
You can copy SQL code from your
Oracle Application Express regions,
LOVs, and validations; paste it into
a SQL worksheet in Oracle SQL
Developer; and execute the query.
Oracle SQL Developer lets you enter
values for the bind variables and run
explain plan or autotrace against the
query to identify performance issues
and tune the SQL.
This columns examples require
Oracle Application Express 3.0.1 or
above and Oracle SQL Developer
1.2.1 or above. (Note that you cannot
perform the examples steps on the
hosted version of Oracle Application
Express at apex.oracle.com.) You also
need an Oracle Application Express
workspace associated with the sample
HR schema available in the default data-
base installation.
BROWSING ORACLE APPLICATION EXPRESS
INFORMATION
In Oracle SQL Developer, create a con-
nection to the HR schema. See the
Oracle SQL Developer column Making
Database Connections in this issue of
Oracle Magazine for step-by-step instruc-
tions on making connections from
Oracle SQL Developer to a database.
Once the connection is established,
you can see an Application Express
node under the HR connection in
Connections Navigator, as shown
(under the XE DPeake connection) in
Figure 1.
You can now browse the HR users
Oracle Application Express applications,
using the detail tabs in Oracle SQL
Developer, as shown in Figure 2.
REMOTE DEBUGGING
You can use Oracle SQL Developer to
debug PL/SQL remotely. This capability
is especially useful when an application
isnt failing but also isnt producing the
results you expect. As an exercise, follow
these steps to debug a procedure in the
asset manager packaged application
deployed in Oracle Application Express:
Step 1: Obtain and install the packaged
application. Download, import, and
deploy the asset manager application in
Oracle Application Express.
1. Download asset_manager_1.0.zip
from otn.oracle.com/products/database/
application_express/packaged_apps/
packaged_apps.html#ASSETS, and save
the file locally.
2. Unzip the file.
3. In Oracle SQL Developer, connect to
the HR schema.
4. Right-click the Application Express
node under HR in Connections
Figure 1: Oracle Application Express node in Oracle
SQL Developer
MJ08_BROWSER.indd 47 3/13/08 2:26:37 PM
4 8 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
BROWSER-BASED
Navigator, and select Import
Application.
5. Browse to and open the unzipped
asset_manager_1.0 folder, and select
the asset_manager_installer_1.0.sql
file.
6. Click Next.
7. Click the Run Install Script check
box (see Figure 3), and click Next.
8. Click Finish.
9. Click OK in the success window.
Step 2: Configure Oracle SQL Developer for
remote debugging. Set up Oracle SQL
Developer for debugging the applica-
tions EBA_ASSET.update_status
procedure remotely.
1. In Oracle SQL Developer, connect
to the database as a user with DBA
privileges.
2. Enter the following code in the SQL
worksheet. If necessary, replace PUBLIC
with the user defined to run Oracle
Application Express in mod_plsql.
(PUBLIC is correct if youre using
Oracle Database 10g Express Edition.)
grant DEBUG CONNECT SESSION to HR;
grant DEBUG on HR.EBA_ASSET to PUBLIC;
3. Click Run Script (or press F5).
4. Connect as HR.
5. In Connections Navigator, open the
Packages node and click EBA_ASSET.
6. Right-click EBA_ASSET Body, and
select Edit.
7. Right-click in the margin on the detail
pane, and select Toggle Line Numbers.
8. Scroll down to line 113, right-
click in the margin, and select Toggle
Breakpoint.
9. Right-click in the main body, and
select Compile for Debug. (Note that
running a package in debug mode
severely hampers performance. Once
testing is complete, you should recom-
pile the package.)
10. Right-click HR in Connections
Navigator, and select Remote Debug
(see Figure 4).
11. Click OK.
Step 3: Configure Oracle Application Express
for debugging. Set up Oracle Application
Express to debug the EBA_ASSET
.update_status procedure:
1. Log in to Oracle Application Express
tcp(localhost,4000);
END IF;
eba_asset.update_status(:P11_ASSET_ID);
IF :DEBUG = YES THEN
dbms_debug_jdwp.disconnect;
END IF;
This code is designed to fire only
when the page is run in DEBUG mode.
The second IF statement disconnects
the debugging session.
as HR.
2. Click Application Builder.
3. Click Asset Manager 1.0.
4. Click Page 11 Inventory Details.
5. Under Processes, click Update Asset
Status.
6. In the Source box, replace the exist-
ing code with the following:
IF :DEBUG = YES THEN
dbms_debug_jdwp.connect_
Figure 2: Detail tabs for an application
Figure 3: Importing and deploying an application
MJ08_BROWSER.indd 48 3/13/08 2:26:57 PM
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 4 9
7. Click Apply Changes.
Step 4: Run the application. Run the
asset manager application in Oracle
Application Express, first normally and
then in DEBUG mode.
1. In Oracle Application Express, navi-
gate back to page 1 and click Run.
2. Log in as HR.
3. Select Assets.
4. Click the edit icon for any asset
record.
5. Click the edit icon for an inventory
record in that asset record. Change
the status value.
6. Click Apply Changes. The applica-
tion performs normally, because its not
in DEBUG mode.
7. Click on the edit icon for the same
inventory record.
8. Click Debug in the developer toolbar.
9. Change the status value, and click
Apply Changes.
10. Oracle SQL Developer should now
have the desktop focus. (If not, the
application will show a partially com-
plete process and you should navigate
to Oracle SQL Developer manually.)
11. Use the Oracle SQL Developer
debugging controls to resume, step over,
and step into the procedure (see Figure
5). As you step through the procedure,
you can see the data values change.
Once the procedure finishes execut-
ing, the remote debugger disconnects.
You can use remote debugging to
step through complex PL/SQL process-
ing thats not performing its intended
function. Reviewing the data values as
you step through the program helps you
identify incorrect logic.
CONCLUSION
You can use Oracle SQL Developer
to perform the following tasks as
you develop your Oracle Application
Express applications:
O Navigate rapidly through all your
applications components
O Export, import, and deploy
applications
O Tune SQL
O Remotely debug PL/SQL
The combination of Oracle SQL
Developer and Oracle Application
Express can give your Web application
development efforts a significant pro-
ductivity boost. O
David Peake (david.peake@oracle.com) is a principal
product manager in Oracles Server Technologies
division. He has been with Oracle since 1993.
Figure 4: Oracle SQL Developer configured for remote debugging
READ more Browser-Based
otn.oracle.com/oramag/oracle/browser
LEARN more about
Oracle Application Express
apex.oracle.com
Oracle Application Express/
Oracle SQL Developer integration
otn.oracle.com/products/database/application_
express/html/sql_dev_integration.html
DOWNLOAD Oracle Application
Express
otn.oracle.com/products/database/application_
express/download.html
UPGRADE Oracle Application
Express within Oracle Database 10g
Express Edition
otn.oracle.com/products/database/application_
express/html/3.1_and_xe.html
Figure 5: Remote debugging in Oracle SQL Developer
MJ08_BROWSER.indd 49 3/21/08 1:57:05 PM
Writtcn by Icading OracIc profcssionaIs, OracIc Prcss books offcr thc most dcnitivc, compIctc,
and up-to-datc covcragc of OracIc products and tcchnoIogics avaiIabIc. Wc'vc bccn thc prcmicr
sourcc for OracIc information for morc than a dccadc, and thc tradition continucs with thc
rcIcasc of OracIc Databasc 11g.
(=(03()3,,=,9@>/,9,*647<;,9)662:(9,:63+
}on the Cruce lress Communty to be the rst to heur ubout
nev Cruce lress reeuses und specu oers ut
^^^6YHJSL7YLZZ)VVRZJVT
OracIc Databasc 11g Ncw fcaturcs
Robet| C. Iteeman
ucky nd out ubout u the
revoutonury nev eutures uvuube
n Cruce Dutubuse llg so you cun
pun or upgrudes or mgrutons.
OracIc Databasc 11g
DBA Handbook
Bob Bty|a and Iev|n Ioney
1he bestseng, comprehensve
gude to Cruce dutubuse
udmnstruton hus been uy revsed
und upduted or the nev reeuse.
OracIc Automatic Storagc Managcmcnt
Lnder-the-Hood & lructcu Depoyment Cude
!|||n Vengut|elat, Muta|| Va||a|h, and
R|ch Iong
Bu||d and manage a sca|ab|e, h|gh|y
ava||ab|e s|otage |n|tas|tuc|ute u||h Ctac|e
u|oma||c S|otage Managemen| (SM).
OracIc Databasc 11g SQl
/ason It|ce
Access Cruce dutubuses through
SL stutements, construct lL/SL
progrums, und use SL lus und SL
Deveoper n the nev dutubuse reeuse.
OracIc Databasc A]AX & PHP
Wcb DcvcIopmcnt
Iee Batney and M|chae| McIaugh||n
ud und depoy hghy responsve
dutu-drven \eb 2.0 uppcutons.
OracIc Databasc 11g Pl/SQl
Programming
M|chae| McIaugh||n
Desgn und dever robust,
euture-rch lL/SL uppcutons.
Untitled-5 1 3/18/08 8:38:41 PM
BY STEVEN FEUERSTEI N
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 5 1
d e v e l o p e r PL/SQL PRACTICES
On the PGA and Indexing Collections
Best practices for knowing your PGA impact and indexing collections
y DBA wants me to reduce the
amount of PGA (program global
area) memory I use in my
collection-based programs. Isnt it
the DBAs job to manage memory, and if it isnt,
how am I supposed to know how much PGA
memory I am using?
Sure, it is ultimately the responsi-
bility of the database administrator to
analyze memory usage and to either
make the necessary adjustments in the
database configuration or recommend to
the developers what should be changed
in their code.
Having said that, I strongly encour-
age all developers to become as aware of
and as involved as possible in all aspects
of deployment of your code, to ensure
the best-possible results for your users.
It is certainly possible, for example,
for you to measure the amount of PGA
memory your program uses. To do so,
however, you will need to go back to
your DBA and ask that person to grant
SELECT privileges to your schema on
the following views:
SYS.V_$SESSION
SYS.V_$SESSTAT
SYS.V_$STATNAME
Once you can query from these views,
compile the show_pga_memory proce-
dure, shown in Listing 1 (and included
in the show_pga_memory.sp file in the
sample code download for this column,
at otn.oracle.com/oramag/oracle/08-
may/o38plsql.zip), in your schema. You
can then call show_pga_memory after
running your application code to see
how large the PGA has become.
When I used this procedure to test
BULK COLLECT with different LIMIT
clause values, I found that the size of
my PGA ranged from 4,613,072 bytes to
46,883,792 bytes.
INDEXING COLLECTIONS
I want to use associative arrays to quickly look
up an office product name for a given product
number and a product number for a given
product name. Product names are unique, and
product numbers are integers. I see how I can
use the product number as the index value
in my collection of names, but I also need to
reverse the process and find a product number
for a given product name. Can I create another
index on a collections contents?
A collection has only one index,
which is defined explicitly in associative
array types with the INDEX BY clause (as
integer or string) and implicitly in nested
table and varray types (as integer only).
So if you need to find the index
value (location) at which a given
element resides, you will have to do
one of the following:
O Scan the contents of the collection
until you find a match.
O Construct a second collection that will
emulate (act like) an index on the first or
primary collection.
I demonstrate both of these tech-
niques below, based on a set of office
product data that is initialized within the
package body.
Scan until you find it. First, I create a
package whose specification includes a
collection of product names, as shown in
Listing 2.
Suppose I have the name of the pro-
duct and want to find its index value so
that I can remove that element. Listing 3
contains the product_lookup1 function,
which scans the collection until it finds a
match on the name.
This is a very simple program, easy
to understand and maintain. Yet it may
perform inefficiently for large collec-
tionsespecially if I try to locate the
index value for a name that is not in the
list. To do so, I would have to scan the
full contents of the collection. Clearly,
Id rather not have to look through the
collection element by element.
Emulating a table column index. A much
better approach is to follow the example
CREATE OR REPLACE PROCEDURE show_pga_memory (
context_in IN VARCHAR2 DEFAULT NULL
)
IS
l_memory NUMBER;
BEGIN
SELECT st.VALUE
INTO l_memory
FROM SYS.v_$session se, SYS.v_$sesstat st, SYS.v_$statname nm
WHERE se.audsid = USERENV (SESSIONID)
AND st.statistic# = nm.statistic#
AND se.SID = st.SID
AND nm.NAME = session pga memory;
DBMS_OUTPUT.put_line ( CASE
WHEN context_in IS NULL
THEN NULL
ELSE context_in || -
END
|| PGA memory used in session =
|| TO_CHAR (l_memory)
);
END show_pga_memory;
codeLISTING 1: show_pga_memory procedure
MJ08_PLSQL.indd 51 3/13/08 1:12:06 PM
5 2 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
PL/SQL PRACTICES
package body in Listing 5.
I have, first of all, changed the
structure of the body, having moved
the lines of code used to populate the
names collection into its own initialize
procedure. I then call that procedure in
the initialization section of the package.
I find it easier to maintain such code
in its subprogram than to have a long,
complex block of code at the end of my
package. Also, I could now, if necessary,
expose this subprogram in the package
specification so that it can be reinitialized
as needed during a session.
The initialize procedure itself con-
tains a local procedure, add_product,
that takes a name and does two things:
O Adds that name to the list of names
of Oracle Database. If you want to quickly
find a row in a table based on a given
column value, you create an index on
that column. For this question, if I were
working with a relational table, I would
create an index on the product name.
I can do something similar for a
collection, but to do so, I will have to
define a second collection to emulate
the index on a table column. For the
remainder of this column, I will use
the term index collection when referring
to the collection I create to emulate an
index on a table column.
A collection can have only one index,
and my list_of_names collection is
already indexed by product number. So
I will have to create a second collection
and index this one by product name.
Listing 4 shows the modified office_
products package specification.
Note, first of all, that I no longer use
hard-coded declarations for the types ref-
erenced in my collection types. Instead, I
have switched to using subtypes.
This approach is completely optional
but highly recommended. In other
words, I could define my collection types
as follows:
TYPE names_list_aat IS TABLE OF
VARCHAR2(100) INDEX BY PLS_INTEGER;
TYPE index_list_aat IS TABLE OF
PLS_INTEGER INDEX BY VARCHAR2(100);
Both approaches will execute in
exactly the same way. So why bother
with subtypes? Because the resulting
code explains itself much more clearly,
making it easier to understand, debug,
and maintain.
Because Im using subtypes, my
package specification tells mevery
explicitly and without the need for com-
mentsthat I have these two collections
to work with:
O office_products.list_of_names, a list of
the product names indexed by the index
value (product number)
O office_products.index_by_name, a list
of the product numbers indexed by the
product name
Of course, I still need to populate
these collections, so lets look at the
CREATE OR REPLACE FUNCTION product_lookup1 (NAME_IN IN VARCHAR2)
RETURN PLS_INTEGER
IS
c_count PLS_INTEGER := office_products.list_of_names.COUNT;
l_index PLS_INTEGER := office_products.list_of_names.FIRST;
l_return PLS_INTEGER;
BEGIN
WHILE (l_index IS NOT NULL)
LOOP
IF office_products.list_of_names (l_index) = NAME_IN
THEN
l_return := l_index;
l_index := NULL;
ELSE
l_index := office_products.list_of_names.NEXT (l_index);
END IF;
END LOOP;
RETURN l_return;
END product_lookup1;
codeLISTING 3: Function for finding name of product
CREATE OR REPLACE PACKAGE office_products
IS
TYPE names_list_aat IS TABLE OF VARCHAR2 (100)
INDEX BY PLS_INTEGER;
list_of_names names_list_aat;
END office_products;
CREATE OR REPLACE PACKAGE BODY office_products
IS
BEGIN
list_of_names (1567) := Stapler;
list_of_names (75009) := Mousepad;
list_of_names (101) := Pencil sharpener;
END office_products;
codeLISTING 2: Initial office_products package specification and body
CREATE OR REPLACE PACKAGE office_products
IS
SUBTYPE name_t IS VARCHAR2(100);
SUBTYPE index_t IS PLS_INTEGER;
TYPE names_list_aat IS TABLE OF name_t
INDEX BY index_t;
TYPE index_list_aat IS TABLE OF index_t
INDEX BY name_t;
list_of_names names_list_aat;
index_by_name index_list_aat;
END office_products;
codeLISTING 4: Modified office_products package specification
MJ08_PLSQL.indd 52 3/13/08 1:12:15 PM
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 5 3
O Updates the index collection to associ-
ate that product name (the index value of
this string-indexed collection) with the
index value of the original list of names
I then call add_product for each row
in the products table.
With this emulated index in place,
my lookup function now becomes very
simple, as shown in Listing 6. This
function returns the index value for the
specific name, if a row exists for that
name. If not, the function simply returns
NULL. Because NULL is never allowed
as an index value, it is a good indicator
for Sorry, no product with that name.
This second approach, taking advan-
tage of the emulated index, results in
a very simple lookup program, but, of
course, the setup code is more com-
plicated. Increased code complexity is
justified if I can get a substantial boost in
performance. Lets see if that is the case.
Comparing the performance of lookup
programs. I want to compare perfor-
mance for these scenarios:
O Scan collection for a name in the
collection
O Scan collection for a name not in the
collection
O Index find for a name in the collection
O Index find for a name not in the
collection
First I change the initialize procedure
so that I can load a nontrivial volume of
data into the collections (I will no longer
populate the collections in the initializa-
tion section), as shown in Listing 7.
I then construct a compare_lookups
procedure that relies on DBMS_UTILITY
.GET_CPU_TIME to help me calculate
elapsed CPU time down to the hun-
dredth of a second. Listing 8 includes
the code for timing the performance of
the collection scan implementation.
I then call this compare_lookups
procedure with variations in the number
of rows in the collection and the number
of calls to the lookup programs:
BEGIN
compare_lookups (100, 1000);
compare_lookups (1000, 1000);
compare_lookups (100000, 1000);
compare_lookups (100000, 10000);
END;
Listing 9 includes the results I ob-
tained (in hundredths of a second) in an
Oracle Database 10g Release 2 instance
on a laptop with 4GB of memory.
From this data, I draw the following
conclusions:
O For collections with small amounts of
data, you can take either approachthe
scan find or the index findto finding
the index containing a certain element,
CREATE OR REPLACE PACKAGE BODY office_products
IS
PROCEDURE initialize
IS
PROCEDURE add_product (index_in IN index_t, NAME_IN IN name_t)
IS
BEGIN
list_of_names (index_in) := NAME_IN;
index_by_name (NAME_IN) := index_in;
END add_product;
BEGIN
add_product (1567, Stapler);
add_product (75009, Mousepad);
add_product (101, Pencil sharpener);
END initialize;
BEGIN
initialize;
END office_products;
codeLISTING 5: Modified office_products package body
CREATE OR REPLACE FUNCTION product_lookup2 (NAME_IN IN office_products.name_t)
RETURN PLS_INTEGER
IS
l_index PLS_INTEGER;
BEGIN
IF office_products.index_by_name.EXISTS (NAME_IN)
THEN
l_index := office_products.index_by_name (NAME_IN);
END IF;
RETURN l_index;
END product_lookup2;
codeLISTING 6: Modified product lookup (product_lookup2) function
CREATE OR REPLACE PACKAGE BODY office_products
IS
PROCEDURE initialize (count_in IN PLS_INTEGER)
IS
PROCEDURE add_product (index_in IN index_t, NAME_IN IN name_t)
IS
BEGIN
list_of_names (index_in) := NAME_IN;
index_by_name (NAME_IN) := index_in;
END add_product;
BEGIN
list_of_names.DELETE;
index_by_name.DELETE;
add_product (1567, Stapler);
add_product (75009, Mousepad);
add_product (101, Pencil sharpener);
FOR indx IN 1 .. count_in
LOOP
add_product (indx * 1000, Product || indx);
END LOOP;
END initialize;
END office_products;
codeLISTING 7: Modified initialize procedure
MJ08_PLSQL.indd 53 3/13/08 1:12:26 PM
5 4 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
PL/SQL PRACTICES
and performance will be fine.
O For collections with hundreds and
certainly thousands of elements, you
should build an index collection and
use that to find indexes for elements.
Performance is stable regardless of col-
lection counts.
Finally, as with any performance
analysis and conclusions, you should run
the script compare_lookups.sql (avail-
able in the sample code download for
this column) yourself on your version of
Oracle Database and confirm the results.
Dont forget. . . . Collections offer a very
efficient mechanism for looking up data.
Retrieving data from a collection cached
in the program global area is much faster
than doing so from a persistent tables
data cached in the system global area.
You must always remember the fol-
lowing, however, when using package-
level collections in this way:
O The data you are caching in the collec-
tion is static while the user is asking for
the information. If the source of this data
changes (if, for example, it is queried from
a table), your cache will be out-of-date.
O Your database server must have enough
memory (in addition to the SGA alloca-
tion) to handle all the PGAs for each
session connected to Oracle Database
that uses this package-based cache. Each
PGA will have its own copy of the cache.
If you are developing your software
for Oracle Database 11g, you should take
advantage of the function result cache,
which I wrote about in the September/
October issue of Oracle Magazine (On
the PL/SQL Function Result Cache, at
otn.oracle.com/oramag/oracle/07-sep/
o57plsql.html). It offers performance
similar to that of package-based caches
but is shared across all sessions in the
database instance and is automatically
invalidated if any changes are made to
dependent tables.
Regardless of the approach you take,
remember that collections have only a
single index but that you can always add
your own emulated indexes by populat-
ing other collections with the cross-
referencing information. O
Steven Feuerstein (steven@stevenfeuerstein.com) is
Quest Softwares PL/SQL evangelist. He has published
10 books on Oracles programming language, including
Oracle PL/SQL Programming and Oracle PL/SQL Best
Practices (OReilly Media). Feuersteins self-appointed
mission in life these days is to improve the quality and
quantity of PL/SQL code testing.
CREATE OR REPLACE PROCEDURE compare_lookups (
coll_count_in IN PLS_INTEGER
, iterations_in IN PLS_INTEGER
)
IS
l_time_before PLS_INTEGER;
l_index PLS_INTEGER;
BEGIN
office_products.initialize (coll_count_in);
.
.
.
l_time_before := DBMS_UTILITY.get_cpu_time;
FOR indx IN 1 .. iterations_in
LOOP
l_index := product_lookup1 (
Product || TO_CHAR (coll_count_in / 2));
END LOOP;
DBMS_OUTPUT.put_line (
Scan Find - name exists =
|| TO_CHAR (DBMS_UTILITY.get_cpu_time l_time_before));
.
.
.
END compare_lookups;
codeLISTING 8: compare_lookups procedure
READ more
Best Practice PL/SQL
otn.oracle.com/pub/columns/plsql
DOWNLOAD
Oracle Database 11g
otn.oracle.com/software/products/database
sample code for this column
otn.oracle.com/oramag/oracle/08-may/o38plsql.zip
COUNT in collections = 100
Number of times program lookup called = 1000
Scan Find - name exists = 0
Scan Find - name does not exist = 2
Index Find - name exists = 0
Index Find - name does not exist = 0
COUNT in collections = 1000
Number of times program lookup called = 1000
Scan Find - name exists = 12
Scan Find - name does not exist = 11
Index Find - name exists = 2
Index Find - name does not exist = 0
COUNT in collections = 100000
Number of times program lookup called = 1000
Scan Find - name exists = 681
Scan Find - name does not exist = 1391
Index Find - name exists = 0
Index Find - name does not exist = 0
COUNT in collections = 100000
Number of times program lookup called = 10000
Scan Find - name exists = 6578
Scan Find - name does not exist = 14043
Index Find - name exists = 1
Index Find - name does not exist = 0
codeLISTING 9: Results of compare_lookups procedure
MJ08_PLSQL.indd 54 3/13/08 1:12:34 PM
BY CHRI STI AN SHAY
d e v e l o p e r .NET
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 5 5
It Takes All Types
Build applications with Oracle Developer Tools for Visual Studio and Oracle user-defined types.
sing Oracle Data Provider for
.NET (ODP.NET), a high-
performance ADO.NET-
compliant data provider,
developers can take advantage of all of
Oracle Databases enterprise features
with performance tuning and secu-
rity features built in. ODP.NET can be
used in conjunction with
Oracle Developer Tools for
Visual Studio, an add-in for
Microsoft Visual Studio that
makes common database
tasks easy for .NET develop-
ers. For example, you can
create tables, edit and debug
PL/SQL, edit and run SQL
scripts, automatically gener-
ate .NET code to access data-
base schema objects, and do
many other database tasks
right from Visual Studio.
User-defined types
(UDTs) make it possible
to model real-world enti-
ties such as customers or
purchase orders as objects
in Oracle Database, and ODP.NET 11g
has added support for UDTs, so that
developers can access their objects,
VARRAYs, and nested table types from
C# or VB.NET code. Oracle Developer
Tools for Visual Studio also supports
UDTs, enabling you to use Visual Studio
to create and modify them and autogen-
erate .NET code to access them. (UDTs
will be of particular interest to .NET
developers leveraging Oracle Spatial and
Oracle Advanced Queuing, which accept
UDTs as part of their PL/SQL interfaces.
VARRAYs and nested table types are fre-
quently used in PL/SQL business logic.)
In this article, I use both
ODP.NET and Oracle Developer Tools
for Visual Studio to take you, step
by step, through the process of using
Visual Studio to create UDTs in Oracle
Database, and then I create a sample
ASP.NET Web application to display the
value of those objects.
The steps in this article require Visual
Studio 2008 or Visual Studio 2005 and
access to an Oracle Database (Oracle9i
Database or later) instance. You should
also be able to get this articles sample
application working with Visual Studio
.NET 2003, in which case the steps will
be significantly different from those used
in this article.
Youll need to download and install
both Oracle Developer Tools for Visual
Studio and ODP.NET version 11.1
or later. These products are free and
can be downloaded from the Oracle
Technology Network using the link in
nextSTEPS, at the end of this article.
If you are not familiar with the object-
relational features of Oracle Database,
see nextSTEPS to find the URL for
accessing Oracle Database Object-
Relational Developers Guide, which
describes concepts and terminology
used in this article.
DESIGNING THE DATA AND THE APPLICATION
I keep the database design simple while
demonstrating some of the object-
relational features of Oracle Database. To
that end, I first define a simple customer
object type, CUSTOMER_OBJ, that con-
sists of a customer number; a customer
name; an address object, ADDRESS_OBJ;
and a phone number list,
PHONELIST_OBJ (which
will be a VARRAY of as many
as 10 phone numbers). The
CUSTOMER_OBJ objects
will live in the CUSTOMER_
TAB object table. (When
you store objects in an
object table, they become
referenceable, meaning that
you can refer to them via
a pointer, a REF, in other
table columns. You can also
dereference any REF in
SQL statements and in appli-
cation code.) Finally, I create
a CUSTOMER_MEETINGS
relational table that con-
sists of a meeting ID, a
meeting date, a location, and a REF to a
CUSTOMER_OBJ object.
My ASP.NET Web application design
is also very simple: I display all customer
meetings on a Web page, along with all
of the details for each customer. I could
have just as easily created a Winform
(thick client) application, and the steps to
do so are very similar to what I do here
for this ASP.NET Web application.
CREATING USER-DEFINED TYPES
Oracle Databases primary integration
point with Visual Studio is server explorer
(see Figure 1), a tree control that enables
you to view your Oracle Database
schema. Each schema object in server
explorer provides context menu items that
launch various wizards and designers. L
I
N
D
Y
G
R
O
E
N
I
N
G
MJ08_ODT.indd 55 3/17/08 4:21:30 PM
5 6 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
.NET
With Visual Studio, ODP.NET, and
Oracle Developer Tools for Visual
Studio installed and an Oracle Database
schema available, you are ready to start
building the application. First, connect
to Oracle Database. In Visual Studio,
right-click the Data Connections
node of server explorer and select Add
Connection. Make sure that Oracle
Data Provider for .NET is selected, fill
in the connection dialog box with the
necessary database information, and
click OK to connect.
Next, construct the various child
components of the CUSTOMER_OBJ
object, starting with the address object
type. In server explorer, scroll down
to the User-Defined Types node,
right-click it, and select New Object
Type. This launches object designer,
as shown in Figure 2. Enter ADDRESS_
OBJ for Type name. Click Add four
times to create four attributes. Select
each attribute on the left side of the
designer (under Attributes) and then
change its Name and Type on the right
side (under Attribute Properties) using
the following values:
Name Type (Data type)
STREET VARCHAR2(200)
CITY VARCHAR2(200)
STATE CHAR(2)
ZIP VARCHAR2(20)
Note that you can click Preview
SQL>> to see the SQL that is going to be
executed. Click OK to create the type.
Now, create PHONELIST_OBJ, which
is a VARRAY of phone numbers. Again
right-click the User-Defined Types
node, and this time select New Varray
(as shown in Figure 1). This launches
the VARRAY designer. In the Type Name
field, enter PHONELIST_OBJ; in the Limit
field, enter 10; in the Type field, enter
Varchar2; and in the Size field, enter 20.
Then click OK to create the object type.
The last type to define is
CUSTOMER_OBJ. Once again, right
click the User-Defined Types node and
select New Object Type.
Enter CUSTOMER_OBJ for Type name.
As you did when creating ADDRESS_
OBJ, first click Add four times to create
four attributes. Next, select each attri-
bute on the left side of the designer
(under Attributes) and then change
its Name and Type on the right side
Figure 1: Server explorer and context menu
Figure 3: Object table designer
Figure 2: Object designer
MJ08_ODT.indd 56 3/17/08 4:21:38 PM
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 5 7
server explorer, right-click the Tables
node and select New Relational Table.
Enter CUSTOMER_MEETINGS for Table
name. Click Add four times to create four
columns. Next, select each column on the
left side of the designer (under Columns)
and then change its Name and Data
type on the right side (under Column
Properties) using the following values:
Name Data type
MEETING_ID NUMBER
TIME DATE
LOCATION VARCHAR2(20)
CUSTOMER CUSTOMER_OBJ
As before, when selecting the data-
type for the CUSTOMER column, you
will need to look near the bottom of the
Data type list for the CUSTOMER_OBJ
user-defined type. Check the Create as
Ref check box (see Figure 4), and click
Save to create the table.
POPULATING THE OBJECTS WITH DATA
The schema objects have been created in
Oracle Database; now you need to load
data into them. To load the data, you
will execute SQL statements by using the
ad hoc query window that Oracle has
integrated into Visual Studio. In server
explorer, right-click the Tables node and
select Query Window. Enter the SQL in
Listing 1, select all the statements, and
click the green execute toolbar icon to
run them all.
CREATING THE ASP.NET WEB APPLICATION
Now that the database is ready, create
the ASP.NET Web application, by taking
advantage of the automatic .NET code
generation features of Visual Studio. In
the main menu, choose File -> New
Project, and then under Visual C#,
select ASP.NET Web Application.
Choose View -> Toolbox, and then
under the Data section of the Toolbox,
drag and drop a GridView control onto
the ASP.NET design surface. Right-click
the small arrow in the upper right-hand
corner of the GridView control to open
the GridView Tasks pane (see Figure
5). From the Choose Data Source
list, select <New Data Source>. This
will start the datasource configuration
Figure 4: Relational table designer
INSERT INTO Customer_tab
VALUES (
1, John Doe,
Address_obj(111 Lollipop Lane, Redwood Shores, CA, 95054),
PhoneList_obj(415-555-1212)
) ;
INSERT INTO Customer_tab
VALUES (
2, John Smith,
Address_obj(333 Island Drive, Edison, NJ, 08820),
PhoneList_obj(609-555-1212,201-555-1212)
) ;
INSERT INTO Customer_tab
VALUES (
3, Richard Roe,
Address_obj(555 Clay St, San Francisco, CA, 94115),
PhoneList_obj(415-555-1212,650-555-1212, 510-555-1212)
) ;
INSERT INTO Customer_meetings
SELECT 1, 12-JAN-2008, HQ - 200, REF(C)
FROM Customer_tab C
WHERE C.CustNo = 1 ;
INSERT INTO Customer_meetings
SELECT 2, 13-JAN-2008, HQ - 300, REF(C)
FROM Customer_tab C
WHERE C.CustNo = 2 ;
codeLISTING 1: Loading the data
(under Attribute Properties), using the
following values:
Name Type (Data type)
CUSTNO NUMBER
CUSTNAME VARCHAR2(200)
ADDRESS ADDRESS_OBJ
PHONELIST PHONELIST_OBJ
The last two attributes are user-
defined types you just created. You will
find user-defined types at the bottom of
the Attribute Properties Type list, after
all of the standard Oracle datatypes.
Now you need to create an object
table to give the CUSTOMER_OBJ
objects a place to live, so that you can
refer to them in other tables by using
REFs. In server explorer, right-click the
Tables node and select New Object
Table. When the dialog box opens,
enter CUSTOMER_TAB for Table name
and select CUSTOMER_OBJ from the
Object type list (see Figure 3). Click
Save to create the table.
To finish building your database
schema objects, you need to create the
CUSTOMER_MEETINGS table. In
MJ08_ODT.indd 57 3/17/08 4:21:45 PM
5 8 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
.NET
wizard, which will create and configure a
SQLDataSource component that contains
automatically generated ODP.NET data
access code. When the wizard opens,
double-click the database icon. Select the
correct connection, and then continue
to the Configure the Select Statement
screen. Click the Specify a Custom SQL
Statement radio button, click Next, and
enter the following SQL statement in the
text box:
SELECT MEETING_ID, TIME, LOCATION,
DEREF(CUSTOMER)
FROM CUSTOMER_MEETINGS
Note that the SQL includes the SQL
DEREF operator. This makes sure that
the object value is returned, rather than
the REF, which is nothing more than
a large hexadecimal value, similar to a
ROWID. (You could also create an appli-
cation that queries for the REF and then
fetches each object value individually,
using its REF, but that approach is not
covered in this article.)
Click Next and then Test Query
to make sure there are no errors. Then
click Finish. Go to the GridView
Tasks pane again, and click Add New
Column. For Header Text, enter
Customers, and for Data Field, select
DEREF(CUSTOMER).
USING THE CUSTOM CLASS WIZARD
At this point, the GridView and
SQLDataSource controls do not know
what to make of the CUSTOMER_OBJ
types being returned by Oracle
Database. By definition, they are user-
defined, and therefore you must provide
a mapping between the Oracle user-
defined datatype and a .NET class that
will hold the data. To do this, use the
Oracle Custom Class wizard.
In server explorer, go to each of the
three user-defined types you created
(CUSTOMER_OBJ, PHONELIST_OBJ,
and ADDRESS_OBJ) and do the fol-
lowing: Right-click the type name, and
select Generate Custom Class. Then
accept all the defaults until you reach
the end of the wizard, which will add a
C# class file to the project.
The SQLDataSource control will ask
DOWNLOAD
ODP.NET and Oracle Developer Tools for
Visual Studio .NET 11g
otn.oracle.com/dotnet
READ more Shay
cshay.blogspot.com
READ more about object-relational
features
Oracle Database Object-Relational Developers Guide
download.oracle.com/docs/cd/B28359_01/
appdev.111/b28371/toc.htm
the CUSTOMER_OBJ object to render
its value as a string, by calling its
ToString() method, so you need to
modify the ToString() method on
both the CUSTOMER_OBJ and the
PHONELIST_OBJ custom classes. (In this
example, you can ignore the ADDRESS_
OBJ ToString() method, because its indi-
vidual members are rendered explicitly by
the CUSTOMER_OBJ ToString code). For
this sample application, use the code in
Listing 2 for the ToString() methods.
One last thing you need to do is make
sure the HTML tags you are passing back
with the CUSTOMER_OBJ custom class
ToString() method are honored by the
GridView control. Go back to GridView
Tasks, and select Edit Columns. In the
dialog box that appears, under Selected
Fields, select CUSTOMERS. In the
Properties pane on the right, set HTML
Encode to False and then click OK.
RUNNING THE ASP.NET WEB APPLICATION
From the main menu, select Debug ->
Start without Debugging. This starts
a Microsoft Internet Information Server
Web server (built in to Visual Studio)
and also launches a Web browser with
a URL pointing to that Web server. The
Web browser displays a grid containing
the MEETING_ID, TIME, LOCATION,
and CUSTOMERS column data.
Now that you have walked through
the basics, I encourage you to further
exercise the ODP.NET and Oracle
Developer Tools for Visual Studio 11g
releases. Happy coding! O
Christian Shay (christian.shay@oracle.com) is a
principal product manager at Oracle.
Figure 5: Configuring the GridView control
ToString() method for CUSTOMER_OBJ class (in Customer_obj.cs):
public override string ToString() {
return Customer Number: + CUSTNO + <br>Name: + CUSTNAME + <br>Address: +
ADDRESS.STREET + + ADDRESS.CITY + + ADDRESS.STATE+ + ADDRESS.ZIP +
<br>Phone Numbers:<br> + PHONELIST.ToString(); }
ToString() method for PHONELIST_OBJ class (in Phonelist_obj.cs):
public override string ToString()
{
string ret = ;
for (int x = 0; x < m_PHONELIST_OBJ.Length; x++)
{
ret = ret + m_PHONELIST_OBJ[x] + <br>;
}
return ret;
}
codeLISTING 2: ToString() method for custom classes
MJ08_ODT.indd 58 3/21/08 2:22:47 PM
BY DAN VLAMI S
t e c h n o l o g y DATA WAREHOUSE
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 5 9
Accelerating Data Warehouses
Oracle OLAP 11g brings high-performance data warehouse features to Oracle Database 11g.
n option of Oracle Database 11g
Enterprise Edition, Oracle OLAP
11g is a full-featured online
analytical processing engine.
Because Oracle OLAP 11g is embed-
ded in Oracle Database, it benefits from
database scalability, security,
and manageability features.
Key new features in
Oracle OLAP 11g include
database-managed relational
views of a cube, a cube scan
row source that is used by
the SQL optimizer, and
cube-organized materialized
views. This article focuses
on enhancements in Oracle
OLAP 11g, how OLAP cubes
fit into the Oracle data ware-
house, and how they are
used within SQL-based busi-
ness intelligence applications
to provide enriched content
with high performance.
WHY OLAP?
Users queries are often unpredictable.
On different days, the same users will
perform trend analysis, drill down on
specific product lines, and compare a
weeks sales against those of the same
week last year. With standard relational
systems, it is difficult to optimize data
structures that provide consistently good
query performance for such an unpre-
dictable query pattern.
To address this need, DBAs and
designers frequently create a system of
summary tables or materialized views.
OLAP cubes, which provide consis-
tently fast query performance across an
entire data model, often provide a better
alternative to summary management.
Sophisticated calculations can be easily
embedded within the cube to enhance
the analytic content of applications.
These calculations often rely on data
from many rows and interrow calcula-
tions. For example, an OLAP cube might
include a calculation that compares the
current years sales for each region and
product line with those from the same
period last year and two years ago. The
cube structure is optimized to handle
this kind of querying and analysis.
WHY ORACLE OLAP?
Oracle OLAP uses an analytic work-
space in the database to perform OLAP
analysis. Oracle OLAP stores data in the
database as multidimensional cubes,
which are designed for fast incremental
update and query. Cubes are organized
by dimensions, which act as keys to the
fact data and define the basic structure
of the cube. In many ways, a cube is
similar to a star schema. The cube plays
the role of the fact table, and an OLAP
dimension plays the role of a dimension
table. Dimensions can be simple lists
of members, or they can be organized
into levels and hierarchies. Hierarchical
dimensions enable data to be aggregated
from lower levels to higher levels of
summarization. They support naviga-
tion such as drill-down and certain types
of calculations such as Share to Parent,
Share within Ancestor, and Rank within
Parent. They also support many time-
series calculations such as Year to Date.
These types of calculations
are easy to define within the
analytic workspace manager
(the administrative tool of
Oracle OLAP 11g) and are
efficiently computed within
the cube at runtime.
Oracle OLAP 11g can
significantly shorten query
processing times for users of
SQL-based business intel-
ligence (BI) tools such as
Oracle Business Intelligence
Suite Enterprise Edition
and other third-party tools.
Oracle OLAP 11g also
makes it easy to embed
computations in an OLAP
cube. Oracle OLAP 11g capabilities are
all provided within Oracle Database,
which allows for centralized control of
data, business rules, and security.
CREATING CUBE-ORGANIZED MATERIALIZED
VIEWS FOR SUMMARY MANAGEMENT
Cube-organized materialized views
are a new capability in Oracle OLAP
11g that enables cubes to be used as a
summary management solution, often
replacing relational summary tables
and table-based materialized views. In
this scenario, an application queries the
fact table by using aggregation func-
tions (such as SUM) and a GROUP BY
clause, and the query rewrite feature of
the database automatically redirects the
query to the cube-organized material-
ized view. The cube manages summary
data transparently to the querying
application, and users benefit from D
A
N
H
U
B
I
G
MJ08_OLAP_11g.indd 59 3/14/08 3:28:45 PM
6 0 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
DATA WAREHOUSE
improved query performance.
To create a cube-organized material-
ized view, DBAs build a cube from the
fact and dimension tables that applica-
tions currently query. They then enable
the cube to allow materialized view
refresh and query rewrite. The materi-
alized view can be created via an API
call or, more commonly, via certain
options in the analytic workspace
manager, as shown in Figure 1. The
cube is self-indexing and manages the
entire aggregate space.
Build the GLOBAL sample cube. To create
and use the GLOBAL sample OLAP
cube and walk through the Oracle OLAP
11g capabilities this article describes,
install and set up the products, schema,
and workspace as follows:
1. Install the Oracle Database 11g
database server and client. Note that
the server and client are separate
downloads, both available on Oracle
Technology Network at otn.oracle.com.
From this page, select Downloads ->
Database, and then click the See All
link next to the name of your operat-
ing system in the Oracle Database
11g download section. When install-
ing the database server, you can use
default options. When installing
the client, make sure you select the
Administrator option to install the
extended set of tools, which includes
the analytic workspace manager.
2. Download the GLOBAL schema
(global_11g_schema.zip) from otn
.oracle.com/products/bi/olap. From
this page, click the 11.1 link next to
the Global Schema selection in the
Downloads section of this page. Unzip
the file contents to a directory.
3. Download otn.oracle.com/oramag/
oracle/08-may/o38olap.zip, and unzip
the contents, the global_oramag.xml file,
to a directory.
4. Follow the directions specified in the
global_11g_readme.html documentation
file, which is provided in the GLOBAL
schema zip file downloaded in step 2.
These directions enable you to create the
GLOBAL schema with the tables neces-
sary to build an analytic workspace.
5. Launch the analytic workspace
manager. From the Windows Start menu,
you can find it at {Oracle11g Client
Home} -> Integrated Management
Tools -> Oracle OLAP Analytic
Workspace Manager and Worksheet.
6. Create a connection to your instance,
by right-clicking Databases and select-
ing Add Database to tree. . . . Enter a
description for the connection and the
appropriate connection string for your
instance (such as localhost:1521:orcl11).
Then click Create.
7. Expand the Database tree until your
new connection appears, and then click
+ (plus sign) next to your connection to
connect to the instance. Enter GLOBAL
for the username, and enter the pass-
word you assigned in step 4.
8. Expand the Schemas tree until you
see Analytic Workspaces. Right-click
Analytic Workspaces, and select
Create Analytic Workspace from
Template. . . .
9. Navigate the file chooser to find the
global_oramag.xml template file you
downloaded in step 3. Choose this file,
and click Create. Wait for a few minutes
while it creates the analytic workspace.
10. Right-click the new GLOBAL ana-
lytic workspace, and select Maintain
Analytic Workspace GLOBAL.
11. Click >> (Add All), and then click
Finish. This step loads data into the
cube and aggregates it according to the
settings specified in the template file.
It may take a few minutes to complete.
Once youre done, click Close to close
the build log.
Run the OLAP query. With the GLOBAL
cube loaded and the data aggregated,
now enter the following
SELECT t.calendar_year_id time,
p.class_id product,
c.region_id region,
SUM(f.sales) sales
FROM time_dim t,
product_dim p,
customer_dim c,
units_fact f
WHERE t.month_id = f.month_id
AND p.item_id = f.item_id
AND c.ship_to_id = f.ship_to_id
AND c.region_id = AMER
GROUP BY t.calendar_year_id,
p.class_id,
c.region_id
ORDER BY t.calendar_year_id,
p.class_id;
Figure 1: Analytic workspace manager
MJ08_OLAP_11g.indd 60 3/14/08 3:29:01 PM
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 6 1
using Oracle SQL Developer (or
another SQL tool of choice). This typical
OLAP query summarizes the data in the
UNITS_FACT fact table by year, class,
and region for only those rows that have
a REGION_ID value of AMER.
If there were no summary tables, this
query would have to sift through the
CUSTOMER_DIM (dimension) table
to find all rows with REGION_ID=AMER
and then find rows in the fact table with
those SHIP_TO_ID values. Finally, it
would have to summarize the SALES
column in the fact table, grouping the
data by year, class, and region.
With Oracle OLAP 11g, using mate-
rialized views, these totals are imme-
diately accessible. It simply fetches the
rows of summarized data and returns
them to the SQL processor. The result
is much faster query response, with a
simple summary management system
that is easy to maintain.
If you run an explain plan against
the query, youll see that the Oracle opti-
mizer uses the CUBE_SCAN operation
instead of the much less efficient HASH
JOIN operation, which is required when
you dont have the materialized view. To
see the difference, execute the commands
alter materialized view cb$units_cube
disable query rewrite
and
alter materialized view cb$units_cube
enable query rewrite
and view the resulting explain plans in
each case. You will also see a huge dif-
ference in performance. In my tests on
the small (300,000 lowest-level rows)
GLOBAL fact table, I found that with
the query rewrite feature enabled (using
the cube), the query returned results
two to five times as fast as without the
cube. You will find larger differences in
performance when using larger, more-
realistically sized cubes.
The summary management system is
also easy to maintain. It has one material-
ized view, rather than a separate material-
ized view for each combination of levels
of each dimension. You can control the
SELECT t.long_description time,
p.long_description product,
cu.long_description region,
ch.long_description channel,
ROUND(u.sales) SALES,
ROUND(u.sales_ytd) YTD,
ROUND(u.sales_ytd_dif_yrago) DIFF,
ROUND(u.sales_ytd_pct_dif_yrago, 6) PCT
FROM time_view t, product_view p, customer_view cu, channel_view ch, units_cube_view u
WHERE t.dim_key = u.time
AND p.dim_key = u.product
AND cu.dim_key = u.customer
AND ch.dim_key = u.channel
AND (t.level_name IN(CALENDAR_YEAR, CALENDAR_QUARTER)
OR t.time_calendar_quarter_id = CY1999.Q1)
AND p.level_name IN(CLASS, TOTAL)
AND cu.level_name = TOTAL
AND ch.level_name = TOTAL
AND p.dim_key = CLASS_SFT
ORDER BY t.end_date, t.time_span;
codeLISTING 1: Quarterly sales and comparison query
Figure 2: Quarterly and comparison results
standard relational engine.
Year-to-date and share calculations
are good examples of calculations that
perform better with Oracle OLAP. Once
defined in the analytic workspace as
calculated measures, these measures are
exposed as extra columns in a view that
is automatically created for a cube. You
can then query these measures just as
you would query any base measure from
the cube view.
When working with cube views,
bear in mind that the view contains pre-
aggregated data at multiple levels. As a
result, you do not need to include any
aggregation functions such as SUM, and
you generally do not need GROUP BY
clauses. But you must also specify the
extent to which the data is precomputed,
but the cube always presents itself as fully
solved for every combination of the levels
of the dimensions involved. A material-
ized view log keeps track of the rows that
change in the base table, and it controls
how much of the cube is incrementally
updated and aggregated and when.
ADDITIONAL CALCULATIONS EXPOSED
THROUGH AUTOMATIC VIEWS
You can use cubes in Oracle OLAP 11g
as a summary management solution, but
Oracle OLAP 11g really shines when you
use it to perform calculations. Oracle
OLAP can perform many calculations
that can be difficult to express in SQL
and time-consuming to perform with the
MJ08_OLAP_11g.indd 61 3/14/08 3:29:19 PM
6 2 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
DATA WAREHOUSE
READ online-only article content
otn.oracle.com/oramag/oracle/08-may/o38olap.html
READ more about Oracle OLAP
otn.oracle.com/products/bi/olap
Building Analytic Workspaces
otn.oracle.com/oramag/oracle/05-nov/o65awm.html
Oracle OLAP 11g Release 1 Users Guide
oracle.com/pls/db111/to_pdf?pathname=olap.111/
b28124.pdf
DOWNLOAD sample data for this article
otn.oracle.com/products/bi/olap
otn.oracle.com/oramag/oracle/08-may/o38olap.zip
level of data you want to select via the
appropriate WHERE clause.
Enter the query in Listing 1 into
Oracle SQL Developer (or your SQL
tool of choice) to look at quarterly sales
and see how those sales compare on a
year-to-date basis with the same periods
last year. The query also shows how to
return multiple levels of the time dimen-
sion in one query.
Executing the query in Oracle SQL
Developer returns the results shown in
Figure 2. Note how rows are returned
for years, quarters, and three specified
monthsall in one view.
This example shows only the most-
basic calculations Oracle OLAP 11g can
perform. A new calculated measure
wizard in the analytic workspace
manager enables you to calculate shares,
indexes, ranks, moving aggregates,
cumulative aggregates, and user-defined
expressions. You can even calculate
models, forecasts, and regressions.
REFRESHING CUBES, USING
MATERIALIZED VIEWS
As fact tables acquire new data, Oracle
Database must maintain cubes and
recalculate totals. You can simplify this
procedure by taking advantage of the
materialized view refresh capability in
Oracle Database. By checking the Enable
Materialized View Refresh of the Cube
check box (shown in Figure 1), you can
specify the refresh of an analytic work-
space to be the same as the refresh of any
other materialized view. For example, to
refresh the GLOBAL analytic workspace,
use the following command:
dbms_mview.refresh(CB$UNIT_CUBE, F)
This command reloads the analytic
workspace from the fact table and
recalculates any aggregates that need
updating. The mechanisms and syntax
are exactly the same as with noncube
materialized views, with methods for
controlling aspects such as staleness and
schedules. The materialized view logs
identify which portions of the cube need
reloading. Oracle OLAP then uses this
information to reload and recalculate the
appropriate portions of the cube.
AGGREGATION
Oracle OLAP always returns data as
fully solved, but you have control over
the extent to which the data is pre-
aggregated. In Oracle OLAP 10g, you
could specify which levels of the cube
to preaggregate. That capability is still
supported in Oracle OLAP 11g, but
now you can also specify the percentage
of the cube you want to preaggregate.
Oracle OLAP will then figure out which
areas of the cube to preaggregate and
which areas to aggregate on the fly.
Oracle OLAP figures out how to balance
runtime performance against load per-
formance and the time needed to calcu-
late certain aggregates. Figure 3 shows
a cube creation dialog box that specifies
20 percent preaggregation.
The online version of this article, at
otn.oracle.com/oramag/oracle/08-may/
o38olap.html, discusses other ways to
present Oracle OLAP data and more
Oracle OLAP 11g new features.
CONCLUSION
With the enhanced capabilities in Oracle
OLAP 11g, it is much easier to incorpo-
rate OLAP into the framework of a data
warehouse. Key improvements such
as materialized views, automatic view
creation, and aggregation wizards make
Oracle OLAP a compelling choice for
accelerating query performance. O
Dan Vlamis (dvlamis@vlamis.com) is president of
Vlamis Software Solutions, Inc. He has been working
with Oracle business intelligence products since
1986. He gives presentations regularly at major Oracle
conferences and is a recognized Oracle OLAP and
Oracle business intelligence expert.
Figure 3: Cube creation dialog box specifying 20 percent preaggregation
MJ08_OLAP_11g.indd 62 3/14/08 3:29:39 PM
BY SUE HARPER
t e c h n o l o g y SQL DEVELOPER
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 6 3
Making Database Connections
Connect to Oracle and third-party databases from Oracle SQL Developer.
racle SQL Developer enables
developers and DBAs to browse,
create, and update data in a
database. Before you can perform
those actions, however, you must create
at least one database connectionan
Oracle SQL Developer object containing
the information needed to connect to a
specific database as a specific user.
This column explains how to make
connections from Oracle SQL Developer
to an Oracle Database and third-party
databases. It also discusses authorization
options for Oracle Database connections
and explains the role of JDBC drivers in
the connection process.
All the examples in this column
require Oracle SQL Developer to be
running on your local machine. For
some examples, you need access to a
running local or remote Oracle Database
instance with the sample HR schema
(available in the default database instal-
lation). Other examples require access to
an Oracle Internet Directory server or a
third-party database.
BASIC CONNECTIONS
You can connect to a local or remote
Oracle Database instance by using the
Basic connection type. Basic connections
do not require any other Oracle software
to be installed on your machineyou
dont need an Oracle home.
Right-click the Connections node
in Oracle SQL Developers Connections
Navigator, and click New Connection
to open the New / Select Database
Connection dialog box. All of this col-
umns connection examples start from
this dialog box.
To create a basic connection for the
HR schema, follow these steps:
1. Enter HR_ORCL for Connection
Name. The connection name is an
arbitrary alias; conventionally, its a com-
bined username and database name.
2. Enter hr for Username, and enter the
hr password in the Password field. (If
you check the Save Password box, the
password will be stored as an encrypted
file on your local machine.)
3. Select Basic from the Connection
Type list.
4. Provide information for the following
settings:
O Role: This is the set of privileges to be
associated with the connection. Accept
default for this connection.
O OS Authentication: Leave this
unchecked for this connection.
O Proxy Connection: Leave this
unchecked for this connection.
O Hostname: This is the host system for
the Oracle Database instance. Enter an
IP address, a machine name, or localhost
(when connecting to a database on the
same machine as Oracle SQL Developer).
The default is localhost.
O Port: This is the listener port for the
database. The default port for Oracle
Database is 1521.
O SID: This is the system identifier, such
as orcl (the default for Oracle Database
10g and Oracle Database 11g) or xe (the
default for Oracle Database 10g Express
Edition). Service name: This is the
network service name of the database.
Select either SID or Service name.
5. Click Test to validate the new connec-
tion. Figure 1 shows the dialog box after
the connection has validated successfully.
6. If your test reports Status: Success,
click Connect. Oracle SQL Developer will
save the new connection, close the dialog
box, and connect to the database. (If you
click Save instead of Connect, you will
be able to create more new connections in
the dialog box before connecting.)
Now HR_ORCL appears in
Connections Navigator, and you can
expand it to browse the database.
TNS CONNECTIONS
The TNS connection type is an appro-
priate option in any of the following
Figure 1: Basic database connection type
MJ08_SQLDEV.indd 63 3/14/08 3:24:20 PM
6 4 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
SQL DEVELOPER
circumstances:
O You have an Oracle client installed
on your machine.
O You have access to many Oracle
Database instances.
O You do not know the machine details
of the system hosting the Oracle Database
instance you want to connect to.
A TNS connection uses an alias entry
from a tnsnames.ora file. Oracle SQL
Developer uses only one tnsnames.ora
file. You may have more than one on
your local machine or want to use the
tnsnames.ora file on a remote machine,
so note that Oracle SQL Developer looks
sequentially for the tnsnames.ora file in
the following locations:
1. $HOME/.tnsnames.ora
2. $TNS_ADMIN/tnsnames.ora
3. /etc/tnsnames.ora (non-Windows
systems)
4. $ORACLE_HOME/network/admin/
tnsnames.ora
5. Registry key
On Windows systems, if a tnsnames
.ora file exists but Oracle SQL Developer
isnt using it, create a TNS_ADMIN envi-
ronment variable via Control Panel ->
System -> Advanced -> Environment
Variables, specifying the files location
as the variables value.
Follow these steps to create a TNS
connection in Oracle SQL Developer:
1. In the New / Select Database
Connection dialog box, enter the same
connection name, username, and pass-
word you used for the basic connection.
2. Select TNS from the Connection
Type list. The GUI changes slightly to
provide a list of all network alias entries
available to you. Select an alias.
3. Click Test and Connect as before.
LDAP CONNECTIONS
Oracle Internet Directory is a directory
service that enables you to store and
manage network service names centrally.
With it, user identity information can be
stored in a directory instead of in mul-
tiple databases. Oracle Internet Directory
is an implementation of the LDAP direc-
tory service and a component of Oracle
Identity Management. For information
on how to install, set up, and configure
Oracle Internet Directory, see the Oracle
Internet Directory Administrators Guide at
otn.oracle.com/documentation/oid.html.
To look up database services in
Oracle Internet Directory and create
an LDAP connection in Oracle SQL
Developer, follow these steps:
1. In the New / Select Database
Connection dialog box, enter a new con-
nection name, username, and password
for the database user.
2. Select LDAP from the Connection
Type list.
3. Select a server from the LDAP Server
list, which is populated with entries
from an ldap.ora file (similar to the
tnsnames.ora file). Alternatively, you can
enter LDAP server details directly.
4. Fill in the LDAP Admin User and
LDAP Admin Password fields.
5. Click Load to populate the DB
Service list with all the database service
entries from Oracle Internet Directory.
6. Select a service from the DB Service
list, as shown in Figure 2.
7. Click Test and Connect as before.
OTHER AUTHENTICATION OPTIONS
Alternatives to database authentication
and LDAP authentication include oper-
ating system (OS) and proxy authenti-
cation. You can create connections in
Oracle SQL Developer for users who
authenticate with these mechanisms.
OS authentication. With OS authentica-
tion, Oracle Database uses a database
users OS login credentials to authenti-
cate that user. The user doesnt provide
a username or password to access the
database, and Oracle Database doesnt
store and manage the account password.
Local OS authentication can be used
when the client and the database server
are on the same machine. Remote OS
authentication is possible but is not
considered secure.
To configure local OS authentica-
tion for a new user, first find the value
of the OS_AUTHENT_PREFIX database
initialization parameter in your systems
init.ora file. When you create this new
user in the database, you must add this
parameter value as a prefix to the OS
username. The default value is OPS$,
for backward compatibility with earlier
database releases. (If the value is , the
OS username and the database username
are the same, so you dont need to add a
prefix to create the Oracle usernames.)
Establish a basic connection with the
HR schema as the SYSTEM user. Execute
the following from the SQL worksheet,
using your databases OS_AUTHENT_
PREFIX prefix and substituting your own
OS username for sue:
CREATE USER ops$sue IDENTIFIED
EXTERNALLY;
GRANT Connect, resource to sue;
Figure 2: LDAP connection with a list of database services
MJ08_SQLDEV.indd 64 3/14/08 3:24:27 PM
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 6 5
Now create a basic connection for
this user from the New / Select Database
Connection dialog box. Enter a connec-
tion name; select Basic for Connection
Type; fill in the Hostname and Port
fields; select OS Authentication; and
provide a SID or Service name. Click
Test and Connect as before.
Proxy authentication. Proxy authentica-
tion means that one JDBC connection
acts as a proxy for other JDBC connec-
tions. Before you can create a connec-
tion that uses proxy authentication,
you need a proxy user. In the following
example, you create a new user named
HR_PROXY_USER and connect that user
through the existing HR user.
To create the new proxy user (HR_
PROXY_USER) and grant the correct
proxy authentication privileges, execute
the following in the SQL worksheet:
CREATE USER HR_proxy_user IDENTIFIED
BY <password>;
ALTER USER HR_proxy_user GRANT
CONNECT THROUGH HR AUTHENTICATED
USING PASSWORD;
You also need to grant any other
privileges required by the new user, such
as CREATE SESSION.
Once your proxy user exists, you can
create a new proxy connection for HR
in Oracle SQL Developer. Select Proxy
Connection in the New / Select Database
Connection dialog box, and complete the
details in the Oracle Proxy Connection
dialog box, as shown in Figure 3.
CONNECTING TO THIRD-PARTY DATABASES
Oracle SQL Developer supports brows-
ing and reviewing data and objects in
Microsoft Access, MySQL, Microsoft SQL
Server, and Sybase. It also offers a SQL
worksheet for ANSI SQL commands to
update or create objects for these data-
bases. Users who want to migrate from
third-party databases to Oracle Database
can use the Oracle SQL Developer
Migration Workbench. For any of these
situations, you need to create a connec-
tion to your third-party database.
Installing third-party drivers. The correct
third-party driver must be installed
before you can create the connection.
You can install third-party drivers either
manually or by using Check for Updates
(Help->Check for Updates). For manual
installation, you can download supported
drivers from the following locations:
O MySQL JDBC driver, version 5.08:
dev.mysql.com/downloads/connector/
j/5.0.html.
O jTDS driver, version 1.2 (required by
Microsoft SQL Server and Sybase): source
forge.net/project/showfiles.php?group_
id=33291. (See jtds.sourceforge.net for
information about this driver.)
Microsoft Access does not require
an additional driver, because it uses a
JDBC/ODBC bridge.
After downloading the driver you
need, expand the driver binary Java
Archive (JAR) file, which is typically
inside the downloaded archive file:
O The mysql-connector-java-5.0.8.tar.gz
(or .zip) download for MySQL includes
mysql-connector-java-5.0.8-bin.jar.
O The jtds-1.2-dist.zip file for Microsoft
SQL Server and Sybase includes
jtds-1.2.jar.
Select Tools -> Preferences ->
Database -> Third Party JDBC Drivers.
Click Add Entry, and add your specific
JAR file. Now you can create a connec-
tion for your third-party database.
The online version of this column,
at otn.oracle.com/oramag/oracle/08-may/
o38sql.html, includes the steps for creat-
ing connections to third-party databases
and explains Oracle JDBC drivers and
driver compatibility.
CONCLUSION
Oracle SQL Developer provides an array
of alternatives for connecting to Oracle
and third-party databases. Support for
both Oracle JDBC Type IV (thin) and
Type II (thick) drivers lets you access
Oracle Databases via basic, TNS, or
LDAP connection types. You can make
connections for Oracle Database users
who authenticate via database, OS, or
proxy authentication. Connecting to a
third-party database from Oracle SQL
Developer lets you work in that data-
base and gives you a starting point for
migrating to Oracle Database. O
Sue Harper (sue.harper@oracle.com) is an Oracle
senior principal product manager based in London.
Figure 3: Creating a proxy connection
READ online-only column content
otn.oracle.com/oramag/oracle/08-may/o38sql.html
READ more about
Oracle SQL Developer
otn.oracle.com/products/database/sql_developer
Oracle JDBC drivers
otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm
READ more Harper
sueharper.blogspot.com
MJ08_SQLDEV.indd 65 3/14/08 3:24:35 PM
oracle.com/goto/ecm
or call 1.800.ORACLE.1
Copyright 2008, Oracle. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Best
Enterprise Content
Management
2008 InfoWorld
Technology of the Year Awards
*
Oracle Universal Content Management
an excellent offering.
InfoWorld, November 8, 2007
*InfoWorld, January, 2008
Untitled-6 1 3/18/08 8:44:15 PM
BY SUSHMA JAGANNATH
t e c h n o l o g y INSIDE OCP
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 6 7
Back Up and Recover
New backup and recovery features in Oracle Database 11g save time and data.
sound database backup and
recovery plan is crucial to pro-
tecting data in the event of
media loss and physical cor-
ruption on production storage systems.
Oracle backup and recovery technolo-
gies enable data to be recovered from
media loss and corruption, as well as
from logical errors at the row, table, and
database level. This column discusses
some of the new backup and recovery
features in Oracle Database 11g that
improve the manageability of Oracle
Database backup and recovery. The
column also presents sample questions
of the type you may encounter when
taking the Oracle Database 11g: New
Features for Administrators exam, which
enables Oracle Certified Professionals
(OCPs) certified on Oracle Database 10g
to upgrade their certifications to Oracle
Database 11g.
DATA RECOVERY ADVISOR
Successfully diagnosing a data failure
and devising an optimal strategy for
repair is critical to maintaining high
availability in the enterprise. Data recov-
ery advisor is an Oracle Database tool
that automatically diagnoses corruption
or loss of persistent data on a disk and
gathers data failure information. It then
determines the best repair option and
checks the feasibility of implementing
the repair in your environment.
Figure 1 shows the automatic diag-
nostic workflow in Oracle Database 11g.
Health monitor automatically diagnoses
failures and logs them into the automatic
diagnostic repository. Data recovery
advisor consolidates these failures and
attaches a severity to them, such as
critical or high. If a DBA requests repair
advice, data recovery advisor maps any
failures to automatic and manual repair
options, checks basic feasibility, and
presents the repair advice. The DBA can
choose to manually execute a repair or
ask data recovery advisor to perform it.
In addition to the automatic, reactive
checks of health monitor and data recov-
ery advisor, Oracle recommends that
DBAs use the VALIDATE command with
the BACKUP and RESTORE commands to
proactively check for corrupt blocks and
missing files and also to confirm that
backups can be restored.
Which of the following failures can data
recovery advisor diagnose and repair?
A. Physical corruption such as block
checksum failures and invalid block
header field values
B. I/O failures such as hardware errors
and operating system driver failures
C. Inconsistencies such as a datafile that
is older than other database files
D. Failures on standby databases
The correct answers are A, B, and
C. Data recovery advisor can detect
and repair physical corruptions related
to blocks, I/O failures, and also any
inconsistencies in datafiles. Option D is
incorrect because data recovery advisor
cannot diagnose and repair failures on
a standby database; it does support
failover to a standby database as a repair
option, however.
PARALLEL BACKUP AND RESTORE FOR
VERY LARGE FILES
In earlier versions, the smallest piece
of an Oracle Recovery Manager (Oracle
RMAN) backup was an entire file.
Because Oracle datafiles can be up to
128TB in size, it is not feasible to back
up a very large file. In Oracle Database
11g, however, Oracle RMAN can break
up a single large file into sections and
back up and restore them indepen-
dently. The SECTION SIZE parameter
in the BACKUP command tells Oracle
RMAN to create a backup set in which
each backup piece contains blocks from
one file section, enabling the backup of
large files to be parallelized across mul-
tiple channels. Restoring a multisection
backup in parallel is automatic.
In your database, the JAN_08_SALES
tablespace contains a single 600MB data-
file. Three system backup to tape (SBT)
channels are configured, with the paral-
lelism setting for the SBT device set to 3.
The MAXSETSIZE is set to 600MB.
You issue the following Oracle RMAN
command:
RMAN> BACKUP
SECTION SIZE 200M
TABLESPACE jan_08_sales;
1. Assess data failures. Health Monitor
5. Perform proactive checks. DBA
2. List failures by severity.
3. Advise on repair.
4. Choose and execute repair.
Data
Recovery
Advisor
Figure 1: Automatic diagnostic workflow in Oracle Database 11g
MJ08_OCP.indd 67 3/13/08 11:41:03 AM
6 8 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
INSIDE OCP
INSIDE OCP
LEARN more about the Oracle
Certification Program, and download a
free exam guide
oracle.com/education/certification
READ Inside OCP columns
otn.oracle.com/oramag/oracle/ocp
What is the outcome?
A. The command creates three backup
sets, each containing one 200MB file
section.
B. The command creates one backup set
containing three 200MB backup pieces.
C. The command creates one backup set
comprising one backup piece that con-
tains three separate 200MB file sections.
D. The command generates an error,
because MAXSETSIZE is larger than
SECTION SIZE.
E. The command generates an error,
because MAXPIECESIZE is not specified.
The correct answer is B. The
command results in an Oracle RMAN
backup set in which each backup piece
contains a file section, which is a con-
tiguous range of blocks in a datafile.
Answers A and C are incorrect because
a multisection backup set contains
multiple backup pieces. Answer D is
incorrect because MAXSETSIZE must be
larger than SECTION SIZE. Answer E is
incorrect because MAXPIECESIZE must
not be specified when SECTION SIZE is
specified, so no error is generated.
ORACLE FLASHBACK TRANSACTION
Flashback transaction enables the
changes made by a transaction to be
undone, optionally undoing changes
made by dependent transactions. This
recovery option uses undo data to create
and execute corresponding compensat-
ing transactions that make the affected
database revert to its original state. The
TRANSACTION_BACKOUT procedure
analyzes transactional dependencies,
performs data manipulation language
(DML) operations, and generates reports.
TRANSACTION_BACKOUT does not
commit the DML operations it performs
as part of the transaction backout, but
it holds all the required locks on rows
and tables, preventing other dependen-
cies from entering the system. To make
the transaction backout permanent, you
must explicitly commit the transaction.
SCOTT executes the following commands
on the REGIONS table in his schema:
SQL>INSERT INTO regions(region_id,
region_name) VALUES (1, North);
SQL>COMMIT;
SQL>UPDATE regions SET region_name =
South WHERE region_id = 1;
SQL>COMMIT;
SQL>DELETE FROM regions
WHERE region_id=1;
SQL>COMMIT;
The UPDATE and DELETE transactions were
a mistake, and you are asked to restore
the original row details: 1, North. You
use the flashback transaction feature for
this operation, and Figure 2 shows the
transaction IDs available for flashback in
Oracle Enterprise Manager. Which trans-
action ID and which change recovery option
must you select to complete the operation?
A. The first transaction ID with the
NONCONFLICT ONLY recovery option
B. The first transaction ID with the
NOCASCADE FORCE recovery option
C. The second transaction ID with the
CASCADE recovery option
D. The third transaction ID with the
NOCASCADE recovery option
The correct answer is C. It backs out
specified transactions and all dependent
transactions in a post-order fashion:
children are backed out before the
parents are backed out. Answer A is
incorrect because the NONCONFLICT
ONLY recovery option backs out
changes to nonconflicting rows of the
specified transactions. Answer B is
incorrect because the NOCASCADE
FORCE recovery option backs out speci-
fied transactions, ignoring dependent
transactions. Answer D is incorrect
because the NOCASCADE recovery
option backs out specified transactions,
which are expected to have no depen-
dent transactions. (It would restore the
row as 1, South.)
CONCLUSION
This column focused on some of the
new backup and recovery features intro-
duced in Oracle Database 11g:
OBy providing a centralized tool for
automated data repair, data recovery
advisor can reduce the mean time to
recovery (MTTR) after a failure. Data
recovery advisor improves the man-
ageability and reliability of an Oracle
Database instance.
OBacking up a file in separate sections
can both improve performance and
enable large-file backups to be restarted.
Using the SECTION SIZE parameter in
the BACKUP command, you can parallel-
ize the backup-and-recovery operation
across multiple channels.
OThe flashback transaction feature
increases availability during logical
recovery, by easily and quickly backing
out a specific transaction or a set of
transactions, and their dependent trans-
actions, with one command while the
database remains online. O
Sushma Jagannath (ocpexam_ww@oracle.com) is
a certification exam development manager at Oracle.
She has been with the company since 2000.
Figure 2: Using Oracle Enterprise Manager Database Control for flashback transaction
MJ08_OCP.indd 68 3/13/08 11:41:13 AM
BY TOM KYTE
t e c h n o l o g y ASK TOM
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 6 9
On Seeing Double in V$SQL
Our technologist looks at SQL repetition in V$SQL and differences in cardinality.
often find more than one row in V$SQL for
a given SQL statement. I am wondering why
that is, which one of those rows represents
the active SQL statement, and which one
users executing that SQL statement in the
database will use. Can you explain?
There are many reasons why more
than one copy of a SQL statement can
be present in V$SQL. For example,
lets say two users each have a table T,
so tables USERA.T and USERB.T are
present in the database. USERA logs
in and queries SELECT * FROM T.
Likewise, USERB logs in and issues
SELECT * FROM T. Even though these
two SQL statements appear to be the
same, they are obviously very differ-
entaccessing different objects with
entirely different query plans. Therefore,
we need two different entries for them
in V$SQL.
In general, there are many reasons
youll see more than one cursor in V$SQL
for a given SQL statement. The follow-
ing discussion explores another pair of
reasons and shows how we can figure
out why there is more than one copy of
the SQL in V$SQL. Well see that in the
end, the cursor version used depends on
the environment of the user running the
SQL statement. Lets start by setting up an
example table to query:
SQL> create table t
2 ( x varchar2(30) primary key,
3 y int );
Table created.
SQL> begin
2 dbms_stats.set_table_stats
3 ( user, T,
4 numrows => 1000000,
5 numblks=>100000 );
6 end;
7 /
PL/SQL procedure successfully completed.
So we have a table, and the optimizer is
told that there are 1,000,000 rows in it.
Now well ensure that the shared pool has
no cached copies of SQL against this table
(this is for demonstration purposesdo
not do this on a production system!):
SQL> alter system flush
2 shared_pool;
System altered.
SQL> select sql_id, sql_text
2 from v$sql
3 where upper(sql_text)
4 like
5 SELECT % T LOOK_FOR_ME %B1_;
no rows selected
So, we have table Ta very simple
tableand now well construct a very
simple PL/SQL block that will execute
the same query text four times, as shown
in Listing 1.
After executing that block, well look
at V$SQL and find that there are four
entriesone each for the identical SQL
statements we executed in Listing 1. We
know they are identical because we can
see that they all have exactly the same
SQL_ID, as shown in Listing 2.
Those four copies may appear identi-
cal, but they are different. Because of the
way I wrote my code, the cursors were
parsed in entirely different environments:
O Cursor 1 used ALL_ROWS and bound
a NUMBER datatype.
O Cursor 2 used ALL_ROWS and bound
a VARCHAR2 datatype.
O Cursor 3 used FIRST_ROWS with a
NUMBER datatype.
SQL> declare
2 l_x_number number;
3 l_x_string varchar2(30);
4 begin
5 execute immediate alter session set optimizer_mode=all_rows;
6 for x in (select * from t look_for_me where x = l_x_number) loop null; end loop;
7 for x in (select * from t look_for_me where x = l_x_string) loop null; end loop;
8 execute immediate alter session set optimizer_mode=first_rows;
9 for x in (select * from t look_for_me where x = l_x_number) loop null; end loop;
10 for x in (select * from t look_for_me where x = l_x_string) loop null; end loop;
11 end;
12 /
PL/SQL procedure successfully completed.
codeLISTING 1: PL/SQL block executing query text four times
SQL> select sql_id, sql_text
2 from v$sql
3 where upper(sql_text)
4 like
5 SELECT % T LOOK_FOR_ME %B1_;
SQL_ID SQL_TEXT
1qqtru155tyz8 SELECT * FROM T LOOK_FOR_ME WHERE X = :B1
1qqtru155tyz8 SELECT * FROM T LOOK_FOR_ME WHERE X = :B1
1qqtru155tyz8 SELECT * FROM T LOOK_FOR_ME WHERE X = :B1
1qqtru155tyz8 SELECT * FROM T LOOK_FOR_ME WHERE X = :B1
4 rows selected.
codeLISTING 2: Query on V$SQL showing same SQL_ID for four query executions
MJ08_ASK TOM.indd 69 3/13/08 2:24:01 PM
7 0 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
ASK TOM
O Cursor 4 used FIRST_ROWS with a
VARCHAR2 datatype.
The differences between cursor pair 1
and 2 and cursor pair 3 and 4 are in the
optimizer settings. Pair 1 and 2 was opti-
mized for ALL_ROWS (total through-
put), and pair 3 and 4 was optimized
for FIRST_ROWS (initial response time).
Additionally, within each pair, we bind
either a VARCHAR2 or a NUMBER type,
and depending on which datatype we
use, we get a different query plan.
Listing 3 shows the plans for cursors
1 and 2. Those two plans (child number
0 and child number 1 here, because
Oracle Database numbers from 0) are
very differentall because of the binds.
When you compare a string with a
number, an implicit to_number() is
placed on the string, as shown in Listing
3. We have not indexed to_number(x), so
we do a full-table scan for the first cursor,
and for the second cursor, bound to a
VARCHAR2, we use the index.
Listing 4 looks at the plans for cursors
3 and 4 (which are child numbers 2
and 3). The plans for cursors 3 and 4
in Listing 4 look the same as those for
the first two cursors (in Listing 3), but
that is just a coincidence. The plans for
cursors 3 and 4 could have been different,
because they were optimized with FIRST_
ROWSfor initial response timenot
ALL_ROWS, as the first two cursors were.
Therefore, because the optimizer mode
is different, there is a different optimizer
environment and hence a different child
cursor. We can see what makes these dif-
ferent, via V$SQL_SHARED_CURSOR:
SQL> select child_number,
2 bind_mismatch B,
3 optimizer_mode_mismatch O
4 from v$sql_shared_cursor
5 where sql_id = 1qqtru155tyz8
6 /
CHILD_NUMBER B O
0 N N
1 Y N
2 N Y
3 Y Y
It shows that child cursors 0 and 1
(the first two cursors) differed in a bind
mismatch (column B) and the next two
cursors differed from the previous ones
because of optimizer mode mismatches
(column O)and the last cursor from the
previous, due to bind mismatch as well.
All four cursors are activeany
of them can and will be used by appli-
cations. If people log in and run that
query, binding a string with FIRST_
ROWS optimization, theyll use the last
child cursor. If people log in and run
that query with ALL_ROWS optimiza-
tion and bind a number, theyll use the
first child cursor.
By using V$SQL_SHARED_CURSOR,
you can gain insight into why there is
more than one copy of a given SQL
statement in the shared pool.
WHY THE CARDINALITY DIFFERENCE?
What are all the possible reasons for the differ-
ence in cardinalities shown in the explain plan
(the guess at the cardinality made by the opti-
mizer) and TKPROF row source operation (what
actually happened at runtime)?
Well, as far as what all the possible
reasons for the difference in cardinalities
shown in the explain plan and TKPROF
row source operation are, there are a
possibly infinite number of reasons, or
at least the list is so large that I cannot
imagine building a comprehensive one.
Take, for example, a case where you
SQL> select * from table( dbms_xplan.display_cursor(1qqtru155tyz8, 0 ) );
PLAN_TABLE_OUTPUT
1 - filter(TO_NUMBER(X)=:B1)
18 rows selected.
SQL> select * from table( dbms_xplan.display_cursor(1qqtru155tyz8, 1 ) );
PLAN_TABLE_OUTPUT
2 - access(X=:B1)
19 rows selected.
codeLISTING 3: Plans for cursors 1 and 2
MJ08_ASK TOM.indd 70 3/13/08 2:24:29 PM
O R A C L E M A G A Z I N E M AY / J U N E 2 0 0 8 7 1
have a set of data called table T. In this set
of data, you have two columns, x and y,
each with 12 distinct values.
You gather every bit of statistics you
canon the table and on each of the
columns (you know the high and low val-
uesin fact you have histograms, so you
know for any of the 12 values of x how
many rows will be returned precisely),
and you have information in every index.
Now, you have a lot of information,
but it wont be enough to answer the
question, How many rows does WHERE
x = ? AND y = ? return? Lets make this
even easier: x is perfectly distributed (the
number of rows returned by x=anything
is 1/12 of the data). Y is the same:
y=anything returns 1/12 of the data.
Now tell me: How many rows does
WHERE x = ? AND y = ? return? Using
high school statistics, we can guess
(assuming that x and y are independent):
rows-returned-by(x) * rows-returned-by(y) =
1/12*1/12 = 1/144
So, about 1/144 of the rows will be
returned from this table T, right? Maybe
maybe not. What if x=y for every row?
Then, well, it is either 1/12 of the rows or
zero rows. That is, if you ask WHERE
x=5 AND y=5, that will return 1/12 (not
1/144) of the rows and for WHERE x=5
AND y=6, youll get zero rows.
Well, the optimizer will pick neither
of those; in general, it will pick 1/144 of
the rows. Consider table T in Listing 5.
So we have table T, it has 49,850 rows,
and we can see that 1/12 of that is about
4,154 rows and 1/144 of that is about
346 rows. Weve gathered very precise
statistics on the table. If we now ask the
optimizer to tell us how many rows it
thinks WHERE x=5, WHERE y=6,
and WHERE x=5 AND y=6 will return,
well discover the results in Listing 6.
The optimizer guessed 1/12, 1/12,
and 1/144 of the data, and for the first
two, it was dead on (due to the way we
constructed our test case), but for the last
one, we know it was way off, because
there are zero records WHERE x=5 AND
y=6 (because x=y for every row!).
In this specific case, a possible solu-
tion for correcting the optimizers guess
is to use dynamic sampling, as shown
in Listing 7 (and demonstrated in more
detail at asktom.oracle.com/tkyte/
DynamicSample.html).
See how the guess of 1 row is much
closer to reality than the prior guess of
357 rows? The optimizer works with
imperfect information at times, and it
makes the best guess. When we see a
large disparity in the computed cardinal-
ity, we can usually see why in that case
and then find a remedy, be it by using
dynamic sampling as demonstrated or
by using a virtual column and gathering
statistics on it (an Oracle Database 11g
Release 1 new featuredemonstrated in
the March/April 2008 Ask Tom column).
SOME DDL JUST GOT EASIER, AND SOME
JUST GOT ADDED
Have you ever encountered something
like this?
SQL> alter table emp add resume blob;
alter table emp add resume blob
*
ERROR at line 1:
ORA-00054: resource busy and acquire
with NOWAIT specified
In a busy system, you may find
certain data definition language (DDL)
operations virtually impossible to
execute, because they do not wait for
existing transactions to finish. You might
SQL> select * from table( dbms_xplan.display_cursor(1qqtru155tyz8, 2 ) );
PLAN_TABLE_OUTPUT
1 - filter(TO_NUMBER(X)=:B1)
18 rows selected.
SQL> select * from table( dbms_xplan.display_cursor(1qqtru155tyz8, 3 ) );
PLAN_TABLE_OUTPUT
2 - access(X=:B1)
19 rows selected.
codeLISTING 4: Plans for cursors 3 and 4
MJ08_ASK TOM.indd 71 3/13/08 2:24:41 PM
7 2 M AY / J U N E 2 0 0 8 O R A C L E . C O M / O R A C L E M A G A Z I N E
ASK TOM
ASK Tom
Tom Kyte answers your most difficult technology questions.
Highlights from that forum appear in this column.
asktom.oracle.com
READ more Tom
Expert Oracle Database Architecture: 9i and 10g
Programming Techniques and Solutions
amazon.com/exec/obidos/tg/detail/-/1590595300/
DOWNLOAD
Oracle Database 11g
otn.oracle.com/software/products/database
execute this ALTER TABLE statement
thousands of times over the course of
many hours, never getting it to go.
Now you have the ability to ask Oracle
Database 11g to put your statement in
a queueto wait for the chance to lock
the table, do the DDL, and give up the
lock. For example, if you issue
SQL> alter session
set ddl_lock_timeout = 6;
Session altered.
in Oracle Database 11g, your DDL state-
ments will wait six seconds before giving
up and returning with a slightly modi-
fied Oracle Database 11g error message:
ORA-00054: resource busy and acquire
with NOWAIT specified or timeout expired
So now a DBA can specify the amount of
time to wait for existing transactions to
complete before having the statement fail.
In addition, some new DDL state-
ments have been introduced in Oracle
Database 11g. One Ive been waiting
for is the ability to put a table in READ
ONLY modepreventing data manipu-
lation language (DML) and DDL modi-
fications. The following puts a table in
READ ONLY mode and then attempts to
run a new DDL statement:
SQL> alter table emp read only;
Table altered.
SQL> alter table emp add resume blob;
alter table emp add resume blob
*
ERROR at line 1:
ORA-12081: update operation not
allowed on table OPS$ORACLE.EMP O
Tom Kyte is a database evangelist in Oracles Server
Technology division and has worked for Oracle since
1993. He is the author of Expert Oracle Database
Architecture: 9i and 10g Programming Techniques
and Solutions (Apress, 2005) and Effective Oracle by
Design (Oracle Press, 2003), among others.
SQL> create table t
2 as
3 select mod(rownum,12) x,
4 mod(rownum,12) y
5 from all_objects
6 /
Table created.
SQL> begin
2 dbms_stats.gather_table_stats
3 ( user, T,
4 method_opt => for all ||
5 columns size 254 );
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> select count(*), count(*)/12, count(*)/144 from t;
COUNT(*) COUNT(*)/12 COUNT(*)/144
49850 4154.16667 346.180556
codeLISTING 5: Query on V$SQL showing same SQL_ID for four query executions
SQL> set autotrace traceonly explain
SQL> select * from t where x = 5;