Pages

OracleEBSpro is purely for knowledge sharing and learning purpose, with the main focus on Oracle E-Business Suite Product and other related Oracle Technologies.

I'm NOT responsible for any damages in whatever form caused by the usage of the content of this blog.

I share my Oracle knowledge through this blog. All my posts in this blog are based on my experience, reading oracle websites, books, forums and other blogs. I invite people to read and suggest ways to improve this blog.


Sunday, April 28, 2013

Cloud Computing

What is Cloud???

The cloud is a computing service that charges you based only on the amount of computing resources we use.

Pay as you go


lVirtualization: 
The ability to run multiple operating systems on a single physical system and share the underlying hardware resources.

Cloud Computing: 
The provisioning of services in a timely (near on instant), on-demand manner, to allow the scaling up and down of resources


Key Characteristics :


Agility
Cost
Device independency
Reliability
Scalability
Security
Sustainability

Components in Cloud Computing :


Client
Services
Application
Platform
Storage
Infrastucture

Normally technology is organized into three layers that are placed like a pyramid:





Cloud Computing Architecture:

Infrastructure as a service (IaaS)
Platform as a service (PaaS)
Software as a service (SaaS)
Network as a service (NaaS)
Storage as a service (STaaS)
Security as a service (SECaaS)
Data as a service (DaaS)
Desktop as a service (DaaS - see above)
Database as a service (DBaaS)
Test environment as a service (TEaaS)
API as a service (APIaaS)
Backend as a service (BaaS)



Software as a Service :

Software as a service feature a complete application offered as a service demand single instance of the software runs on the cloud and services multiple end users or client organization

Ex : Google Apps

Platform as a Service :

Platform as a Service  encapsulates a layer of software and provides it as a service that can be used to build higher level services

2 perspectives for  Platform as a Service

1. Producer
2. Consumer

Infrastructure as a Service :

Infrastructure as a service delivers basic storage and computing capabilities as standardized services over the network

Computing Types :
Cloud computing comes in three forms: public clouds, private clouds, and hybrids clouds. Depending on the type of data you're working with, you'll want to compare public, private, and hybrid clouds in terms of the different levels of security and management required.


Public Clouds

A public cloud is one in which the services and infrastructure are provided off-site over the Internet. These clouds offer the greatest level of efficiency in shared resources; however, they are also more vulnerable than private clouds. A public cloud is the obvious choice when

Your standardized workload for applications is used by lots of people, such as e-mail.

You need to test and develop application code.

You have SaaS (Software as a Service) applications from a vendor who has a well-implemented security strategy.

You need incremental capacity (the ability to add computer capacity for peak times).

You’re doing collaboration projects.

You’re doing an ad-hoc software development project using a Platform as a Service (PaaS) offering cloud.


Private Clouds

A private cloud is one in which the services and infrastructure are maintained on a private network. These clouds offer the greatest level of security and control, but they require the company to still purchase and maintain all the software and infrastructure, which reduces the cost savings. A private cloud is the obvious choice when

Your business is your data and your applications. Therefore, control and security are paramount.

Your business is part of an industry that must conform to strict security and data privacy issues.

Your company is large enough to run a next generation cloud data center efficiently and effectively on its own.


Hybrid Clouds

A hybrid cloud includes a variety of public and private options with multiple providers. By spreading things out over a hybrid cloud, you keep each aspect at your business in the most efficient environment possible. The downside is that you have to keep track of multiple different security platforms and ensure that all aspects of your business can communicate with each other. Here are a couple of situations where a hybrid environment is best.

Your company wants to use a SaaS application but is concerned about security. Your SaaS vendor can create a private cloud just for your company inside their firewall. They provide you with a virtual private network (VPN) for additional security.

Your company offers services that are tailored for different vertical markets. You can use a public cloud to interact with the clients but keep their data secured within a private cloud.

CareerBytes: Top 10 Technical Interview Tips


Introduction

If you are working as a software engineer, there’s probably no doubt that you’ve had to run the gauntlet of technical interviews. Interviewing for technical positions can be difficult because you have to be able to demonstrate your value in terms of “soft skills” such as communication and team work as well as your “hard skills” such as programming and problem solving. Employers in this new tech boom are placing an ever higher premium on applicants who possess a combination of skills. They want competent technical employees who are also able to drive a business. This changed complexity in open positions has caught many seasoned industry vets off-guard and unprepared. However, being able to show that you are a well rounded candidate and can add value to a company on multiple levels can help you get a leg up on your competition. Consider a few of these tips as your prepare for your next job search or interview experience:
  1. Research: Companies are looking for a certain amount of intellectual curiosity from applicants. They want to know how interested you are in the position, the company, and the products they are developing. When an interviewer asks, “Do you have any questions for me?,” the last thing they want to hear is “No.” They want to hear that you’ve spent meaningful time contemplating these issues, and that you have good questions to ask them. A portion of your interview preparation should be devoted to finding out as much as you possibly can about the company, the product, the group, the division and, finally, the position. You can start by asking your recruiter for any links he/she can send you about the business, and then set off and do your own research. Search tools are a great place to start, but you can now also find good information on company blogs, and by using some business research tools such as Hoover’s.
  2. Practice answering technical questions: In almost all interviews for software engineering, developer, or programmer positions, you will most likely be asked to demonstrate your programming skills. This usually takes place on a whiteboard, but you may also be asked to respond to technical questions via email in a specific time limit, or even bring in copies of your sample code. In any case, prior to engaging in your job search and interviewing, spend extra time coding at home. There are great resources for practice coding questions that you can find by searching for “sample technical interview questions.” Two interesting sites out there are General Technical Interview Questions and Microsoft Interview Questions. Many of the questions you will be asked are analytical or academic in nature. Since you don’t often answer these types of questions on a daily basis, it’s a good idea to spend extra time practicing how to answer them. Interviewers will want to evaluate your skills and thinking process without the use of development tools, so your practice should include writing on a whiteboard, writing answers on a piece of paper, or coding in a text application.
  3. Practice answering behavioral questions: You may have heard them all by now, but employers are always surprised that applicants are unprepared with answers to questions as mundane as “what is your greatest strength?” Jobseekers don’t often devote enough time to preparing for these questions because they often think that they are great at answering questions on the fly. While that may be true in real life, during an interview, you may be feeling more nervous than usual, and will have a more difficult time thinking on your feet. You should anticipate as many behavioral questions as possible related to the position. For example, if you are applying for a Program or Product Manager, you may want to spend time thinking about the most difficult customer you have had to deal with, or how you tend to influence others without authority. Check out this sitefor wonderful sample behavior interview questions.
  4. Review the job description: Before you engage in any interview, nail down the specific position they are evaluating you against, and make sure you ask the recruiter for the job description. Many of you have probably had the experience of embarking on interviews without even having a job description, and that’s just not right. With the job description in hand, you can spend time evaluating your skills against their requirements and determining what your strengths and weaknesses might be. If you do have a weak area, you can spend time brushing up your skills, or coming up with a response to how you will come up to speed on that technology. You can also use this as a basis for developing your own questions, or researching the company and position.
  5. Be on time: If you are interviewing in an unfamiliar place, take a dry run to the location several days or the night before the actual interview. You’ll want to arrive at least 10-15 minutes early for your interview, to fill out paper work and settle yourself before your interviewer meets you. Never underestimate getting lost or held up in traffic.
  6. Dress for success: Employers care about appearance when it comes to interviewing potential candidates. They might be the sloppiest person that you have ever met, but they’ll be expecting you to dress the part of the professional. In this industry, rarely are individuals required to wear a full three-piece suit to the office. Most companies have instituted a “business casual” policy or no policy at all. When getting ready for your interview, always ask your recruiter or company contact what the typical dress is for the office. You can never go wrong with being dressed a little more conservatively than everyone else. In general, slacks, dress shoes, and button down shirts are all great choices for the interview.
  7. Be engaged: Turn off your mobile phone, PDAs, and any other electronic communication devices, and devote your full attention to the interviewer. Answering your cell phone during an interview is a major faux pas, and can land you in the “no hire” bin faster then you can say hello. Great interviews usually end up sounding more like a conversation then a Q&A period, so take the time to listen carefully to questions, and ask clarifying questions of your own. Additionally, make appropriate eye contact with your interviewer when answering questions.
  8. Remain composed: Interviews can really be a horrible experience when not done right. Have you been there? Waiting forever to meet with your interviewer, or being asked basic questions. Worse yet, being treated poorly. Unfortunately, this happens, and there is little you can do to predict when it will happen to you. Remember that you’ll catch more flies with honey than vinegar, so even if you are being treated poorly or feeling frustrated, kill ‘em with kindness. Blowing your top in an interview setting is never appropriate, and besides, you never know if you will run into these folks again in another setting or at your next interview.
  9. Follow up: Thank you's are always appreciated by interviewers and recruiters alike. During the interview day, ask your interviewers for their business cards so you have their contact information. These days, you don’t need to send a formal written thank you note, but you should acknowledge that the interviewers took time out of their day to meet with you. A simple email indicating your thanks for their time can go a long way. As a bonus, you may also want to include something you remember specifically about that person, or a question you may have answered. For example try:
    Dear Bob,
    Thank you for taking time out of your busy day to interview me for the software developer position on your team. I thoroughly enjoyed meeting you and members of your team, and think my skills and personality would be a great match for your group. As a side note, I went back and read your whitepaper on optimizing stored procedures and ….
    Cordially,
    Joe Jobseeker
    This shows that you are appreciative of their time, and you took something away from the interview. Interviewers love this!
  10. Don’t let them forget about you: Your interviews are over, and you survived. Now you wait, but don’t wait too long. Even though the recruiter or interviewer is supposed to deliver the results of your interviews, unforeseen circumstances can throw good intentions off course. If several days pass, and you still haven’t heard from your recruiter, it’s not necessarily a bad sign. Follow-up with your recruiter, and politely ask if a result has been reached. All too often, interviewees will assume no news is bad news, and they’ll never contact their recruiter again. This lack of two way communication is what recruiters refer to as allowing a candidate to accidentally "fall through the cracks." While it is the recruiter’s ultimate responsibility to keep you updated, this is your career we’re talking about. If you’ve put in this much effort thus far, you should continue driving the process forward in a professional manner.

Conclusion

Technical interviews have evolved over the past few years to evaluate for a different skill set in potential candidates. Employers are seeking applicants with a wide range of skills, and you must be able to demonstrate that you are able to add value with your technical and business skills. Even if you are an experienced interviewer yourself, it can be a difficult challenge to be on the other side of the fence. Whether you are just starting your job search or in the midst of interviewing, taking time to prepare thoughtfully can help you break the code between what employers are seeking and what you have to offer.

Saturday, April 27, 2013

Five XSLT Basics


I know what you're up against. You've just inherited a new project at work that requires you to learn XSLT, but you don't have a clue where to start. If that's your problem, this article should give you a leg up over the wall. It will quickly cover five basics of XSLT found in the first chapter of Learning XSLT, O'Reilly's new hands-on guide to get you using XSLT with XPath by close of business today.

XSLT Basic #1: What Is XSLT?

Extensible Stylesheet Language Transformations or XSLT is a language that allows you to transform XML documents into XML, HTML, XHTML, or plain text documents. It relies on a companion technology called XPath. XPath helps XSLT identify and find nodes in XML documents; nodes are things like elements, attributes, and other objects in XML. With XSLT and XPath, you can do things like transform an XML document into HTML or XHTML so it will easily display in a web browser; convert from one XML markup vocabulary to another, such as from Docbook to XHTML (seewww.docbook.org); extract plain text out of an XML document for use in some other application, like a text editor; or build new Spanish language document by pulling and repurposing all the Spanish text from a multilingual XML document. This is only a start of what you can do with XSLT. Now that you know what it is, it's time to learn how it works.

XSLT Basic #2: How Does XSLT Work?

The quickest way to get you acquainted with how XSLT works is through a simple example. Consider this ridiculously brief XML document contained in a file I'll call msg.xml:
<msg/>
There isn't much to this document, but it's legal, well-formed XML: just a single, empty element tag with no content (that is, nothing between a pair of tags). For our purposes, it's the source document for the XSLT processing we'll do in a minute. Now you can use the very simple XSLT stylesheet msg.xsl to transform msg.xml:
<stylesheet version="1.0" 
xmlns="http://www.w3.org/1999/XSL/Transform">
<output method="text"/>

 <template match="msg">Found it!</template>

</stylesheet>
You'll notice that XSLT is written in XML. This allows you to use some of the same tools to process XSLT stylesheets that you would use to process other XML documents. Nice.
The first element (start tag, really) in msg.xsl is
<stylesheet version="1.0"
xmlns="http://www.w3.org/1999/XSL/Transform">
This is the document element for stylesheet, one of two possible document elements in XSLT. The other possible document element is transform, which is actually just a synonym for stylesheet. You can use one or the other. Theversion attribute in stylesheet is required, along with its value of 1.0. (We're only dealing with version 1.0 of XSLT here.)
The attribute xmlns on stylesheet is a special attribute for declaring a namespace. It's value ishttp://www.w3.org/1999/XSL/Transform, which is the official namespace for XSLT. An XSLT stylesheet must always have such a namespace declaration in order for it to work. (XSLT stylesheets usually use the xsl prefix, as inxsl:stylesheet, but I am setting the prefix aside for simplicity at the moment. You'll want to use xsl when your stylesheets get only slightly more complex.)
The stylesheet element is followed by the output element which is optional. The value text for the methodattribute signals that you want the output of the stylesheet to just be plain text:
<output method="text"/>
Two other possible values for method in XSLT 1.0 are xml and html. (The output element actually has ten attributes, all of which are optional.)
The next element in msg.xsl is the template element. This element is at the heart of what XSLT does. A template rule consists of two parts: a pattern, such as an XML element in the source document that you're trying to match, and a sequence of instructions. The match attribute of template contains a pattern, a location path in XPath. The pattern in this example is the name of the msg element:
<template match="msg">Found it!</template>
XPath syntax always appears in attribute values, as in the value of match. The sequence of instructions (sometimes called a sequence constructor) contains only the literal text Found it!. Sequence instructions tells an XSLT processor what you want to have happen when the pattern is found in the source. Using this stylesheet, when msg is found in the source by an XSLT processor, it will output the text Found it!. When a template executes its instructions, that template is said to be instantiated. To make this happen, you need an XSLT processor.

Basic #3: How Do I Get XSLT to Work?

An XSLT processor processes a source document with an XSLT stylesheet, producing an output or result. There are lots of free XSLT processors available for download on the web. I'll mention a couple.

Instant Saxon

Michael Kay's free Instant Saxon (saxon.exe) runs on the Windows command line. Download it fromprdownloads.sourceforge.net/saxon/instant_saxon6_5_3.zip. (If the link fails, just try saxon.sourceforge.net). Unzip the file in some directory on your Windows box. Assuming that you have created and saved the files msg.xml and msg.xsldiscussed earlier in the same spot that you unzipped saxon.exe, you can run Instant Saxon from the Windows command line like this:
saxon msg.xml msg.xsl
This command will process msg.xml against the stylesheet msg.xsl and produce the simple result:
Found it!

xRay2

If you prefer a graphical application, Architag offers a free, graphical XML editor with XSLT processing capability called xRay2. It is available for download from www.architag.com/xray. Like Instant Saxon, xRay2 runs only on the Windows platform. Assuming that you have successfully downloaded and installed it, launch xRay2 and open the file msg.xmland then open the file msg.xsl. Now select New XSLT Transform from the File menu. In the XML Document pull-down menu, select msg.xml, and in the XSLT Program pull-down menu, select msg.xsl (if it is not already checked, check Auto-update). The result of the transformation should appear in the transform window of the application.

Xalan

If you are using the Linux operating system or some other Unix flavor, you can run Apache's XSLT processor Xalan C++ (works on Windows, too). In order to run Xalan, you also need the C++ version of Xerces, Apache's XML parser. You can find both Xalan C++ and Xerces C++ on xml.apache.org. After downloading and installing them (follow instructions on the Apache site), you need to make sure that Xalan and Xerces are in your execution path. Now type the following line in a Unix shell window or at a Windows command prompt:
xalan msg.xml msg.xsl
If successful, the following results should be printed on your screen:
Found it!

Basic #4: How Do I Get XSLT to Work in a Browser?

An XSLT processor is probably readily available to you on your computer desktop in the form of a web browser: Microsoft Internet Explorer (IE) Version 6, Netscape Navigator (Netscape) Version 7.1, Mozilla Version 1.4, or Mozilla Firebird 0.7. Each of these browsers has client-side XSLT processing ability already built into them.
The way to apply an XSLT stylesheet like msg.xsl to the document msg.xml in a browser is by using a processing instruction. A processing instruction (PI) allows you to include instructions for an application in an XML document.
You can see a processing instruction in a slightly altered version of msg.xml, which I call msg-pi.xml:
<?xml-stylesheet href="msg.xsl" type="text/xsl"?>
<msg/>
The XML stylesheet PI should always come before the first element in the document (the document element msg inmsg-pi.xml). The purpose of this PI is similar to one of the purposes of the link tag in HTML, that is, to associate a stylesheet with the document. Save msg-pi.xml in a text file with the other files. If you open msg-pi.xml in one of the browsers I mentioned, the built-in XSLT processor in the browser will write the string Found it! on the browser's canvas or rendering space.

XSLT Basic #5: Beware the Built-in Templates

XSLT has a hobgoblin of sorts. It's a feature know as built-in templates. Built-in templates automatically find nodes that are not specifically matched by a template rule, so you can sometimes get results from an XSLT stylesheet that you're not expecting. These built-in templates automatically find text (among other things) in the XML source when no explicit template matches that text. This can rattle your nerves at first, but you'll get comfortable with them soon enough. I'll illustrate an instance where the built-in template matches text in an XML document. The file hobgoblin.xml contains a bit of text in the element msg:
<msg>Spooky!</msg>
To trigger the built-in template for text, the dull-witted stylesheet hobgoblin.xsl will do the trick:
<stylesheet version="1.0" 
xmlns="http://www.w3.org/1999/XSL/Transform">
<output method="text"/>
</stylesheet>
Apply hobgoblin.xsl to hobgoblin.xml with Instant Saxon using this command:
saxon hobgoblin.xml hobgoblin.xsl
And you will get the following result:
Spooky!
Even though hobgoblin.xsl does not contain a template rule, Instant Saxon found the text Spooky! in the msg element by default using a built-in template rule.

Summary

That covers five basics of XSLT 1.0. This article is only a starting point to get you rolling. There is much, much more to learn about XSLT. Of course, Learning XSLT can help you out there. For resources and news for XSLT from the W3C, go to www.w3.org/Style. If you're brave enough to read the specs, go to www.w3.org/TR/xslt/ and www.w3.org/TR/xpath/to learn more about XSLT 1.0 and XPath 1.0. (Versions 2.0 of these specs are in the last stages of development and are found at www.w3.org/TR/xslt20/ and www.w3.org/TR/xpath02/.) You can search the archives of XSL-List (an XSLT mail list hosted by Mulberry Technologies, Inc.) at www.biglist.com/lists/xsl-list/archives/ or join the list atwww.mulberrytech.com/xsl/xsl-list/index.html#subscribing. Wherever you go with XSLT, or wherever it takes you, best of luck.


R12 AR Tables


------------------------------------Vision Instance---------------------------------------------------------
-------------CUSTOMER--------------------------------------
select *
from ra_customers_interface_all;

select *
from ra_customer_profiles_interface;

select *
from hz_cust_accounts
where account_name='Business World';

select *
from hz_cust_acct_sites_all
where cust_account_id=3347
and org_id=204;

select *
from hz_cust_site_uses_all hcsua
where hcsua.site_use_id=1000;
where hcsua.cust_acct_site_id=3634;

select *
from ar_customers
where customer_name='World of Business';
-----------------TRANSACTION----------------------------------
select *
from RA_INTERFACE_LINES_ALL;
RA_INTERFACE_SALESCREDITS
RA_INTERFACE_DISTRIBUTIONS
RA_INTERFACE_ERRORS (details about the failed records)
/

select *
from RA_CUSTOMER_TRX_ALL
where printing_original_date is not null
and sold_to_customer_id=1000
and trx_number=10000069 ;

select *
from RA_CUSTOMER_TRX_LINES_ALL
where customer_trx_id=1600;

select *
from Ra_Cust_Trx_Line_Gl_Dist_All
where customer_trx_line_id in (1802);

select *
from RA_CUST_TRX_TYPES_ALL;

select *
from XLA_DISTRIBUTION_LINKS xdl
where xdl.source_distribution_type = 'RA_CUST_TRX_LINE_GL_DIST_ALL'
and xdl.source_distribution_id_num_1=1314;


------------------RECEIPT---------------------------------

select *
from ar_payment_schedules_all
where customer_trx_id=1600;

select *
from ar_cash_receipts_all;

select *
from AR_RECEIVABLE_APPLICATIONS_ALL
where applied_customer_trx_id=1600;
and payment_schedule_id-1061;

select *
from ar_adjustments_all;

Oracle Materialized Views


A materialized view is a database object that contains the results of a query. The FROM clause of the query can name tables, views, and other materialized views. Collectively these objects are called master tables (a replication term) or detail tables (a data warehousing term). This reference uses "master tables" for consistency. The databases containing the master tables are called the master databases.

When you create a materialized view, Oracle Database creates one internal table and at least one index, and may create one view, all in the schema of the materialized view. Oracle Database uses these objects to maintain the materialized view data. You must have the privileges necessary to create these objects.

Materialized View Log
When DML changes are made to master table data, Oracle Database stores rows describing those changes in the materialized view log and then uses the materialized view log to refresh materialized views based on the master table. This process is called incremental or fast refresh. Without a materialized view log, Oracle Database must re-execute the materialized view query to refresh the materialized view. This process is called a complete refresh. Usually, a fast refresh takes less time than a complete refresh.

A materialized view log is located in the master database in the same schema as the master table. A master table can have only one materialized view log defined on it. Oracle Database can use this materialized view log to perform fast refreshes for all fast-refreshable materialized views based on the master table.

To fast refresh a materialized join view, you must create a materialized view log for each of the tables referenced by the materialized view.

Privileges required
create materialized view
create any materialized view
drop any materialized view
delete any table
insert any table
lock any table
select any table
under any table
update any table
create table
create view

Syntax (Fast Refresh)
CREATE MATERIALIZED VIEW <schema.name>
PCTFREE <integer>
PCTUSED <integer>
TABLESPACE <tablespace_name>
BUILD IMMEDIATE
REFRESH <FAST | FORCE> ON <COMMIT | DEMAND>
<USING INDEX | USING NO INDEX>
INITRANS <integer>
STORAGE CLAUSE

AS (<SQL statement>);

Example:
CREATE MATERIALIZED VIEW mv_simple
TABLESPACE uwdata
BUILD IMMEDIATE
REFRESH FAST ON COMMIT AS
SELECT * FROM servers;

Syntax (Force Refresh)
CREATE MATERIALIZED VIEW <schema.name>
PCTFREE <integer>
PCTUSED <integer>
TABLESPACE <tablespace_name>
BUILD IMMEDIATE
REFRESH <FAST | FORCE> ON <COMMIT | DEMAND> 
AS
 (<SQL statement>);

Example:
CREATE MATERIALIZED VIEW mv_force
TABLESPACE uwdata
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
BUILD IMMEDIATE
REFRESH FORCE ON DEMAND
WITH ROWID AS
SELECT * FROM servers;

Syntax (Complete Refresh)
CREATE MATERIALIZED VIEW <schema.name>
PCTFREE <integer>
PCTUSED <integer>
TABLESPACE <tablespace_name>
REFRESH <COMPLETE | FORCE>
START WITH <date>
NEXT <date_calculation>
[FOR UPDATE]
AS (<SQL statement>);

Example:
CREATE MATERIALIZED VIEW mv_complete
TABLESPACE uwdata
REFRESH COMPLETESTART WITH SYSDATE
NEXT SYSDATE + 1
AS SELECT s.srvr_idi.installstatusCOUNT(*)
FROM servers s, serv_inst i
WHERE s.srvr_id = i.srvr_id
GROUP BY s.srvr_idi.installstatus;

Syntax (Complete Refresh Using Index)
CREATE MATERIALIZED VIEW <schema.name>
[LOGGING] [CACHE]
PCTFREE <integer>
PCTUSED <integer>
USING INDEX
TABLESPACE <tablespace_name>
REFRESH <COMPLETE | FORCE>
START WITH <date>
NEXT <date_calculation>
[FOR UPDATE]
AS (<SQL statement>);

Example:
CREATE SNAPSHOT mv_w_index
LOGGING CACHE
PCTFREE 0 PCTUSED 99
TABLESPACE uwdata
REFRESH COMPLETE
AS SELECT s.srvr_idCOUNT(*)
FROM servers s, serv_inst i
WHERE s.srvr_id = i.srvr_id
GROUP BY s.srvr_id;

Syntax (Prebuilt Table)
CREATE MATERIALIZED VIEW <schema.name>
PCTFREE <integer>
PCTUSED <integer>
TABLESPACE <tablespace_name>
REFRESH <COMPLETE | FORCE>
START WITH <date>
NEXT <date_calculation>
[FOR UPDATE]
AS (<SQL statement>);

Example:
CREATE TABLE mv_prebuilt (
month VARCHAR2(8),
state VARCHAR2(40),
sales NUMBER(10,2));

CREATE MATERIALIZED VIEW mv_prebuilt
ON PREBUILT TABLE WITH REDUCED PRECISION
AS SELECT t.calendar_month_desc AS month,
c.cust_state_province AS state,
SUM(s.amount_sold) AS sales
FROM times t, customers c, sales s
WHERE s.time_id = t.time_id AND s.cust_id = c.cust_id
GROUP BY t.calendar_month_descc.cust_state_province;

Syntax (Enable Query Rewrite)
CREATE MATERIALIZED VIEW <schema.name>
PCTFREE <integer>
PCTUSED <integer>
TABLESPACE <tablespace_name>
REFRESH <COMPLETE | FORCE>
START WITH <date>
NEXT <date_calculation>
[FOR UPDATE]
AS (<SQL statement>);

Example:
set linesize 121
col name format a30
col value format a30

SELECT name, value
FROM gv$parameter
WHERE name LIKE '%rewrite%';

EXPLAIN PLAN FOR
SELECT s.srvr_idi.installstatusCOUNT(*)
FROM servers s, serv_inst i
WHERE s.srvr_id = i.srvr_id
AND s.srvr_id = 502
GROUP BY s.srvr_idi.installstatus;

SELECT * FROM TABLE(dbms_xplan.display);

CREATE MATERIALIZED VIEW mv_rewrite
TABLESPACE uwdata
REFRESH ON DEMAND
ENABLE QUERY REWRITE
AS SELECT s.srvr_idi.installstatusCOUNT(*)
FROM servers s, serv_inst i
WHERE s.srvr_id = i.srvr_id
GROUP BY s.srvr_idi.installstatus;

EXPLAIN PLAN FOR
SELECT s.srvr_idi.installstatusCOUNT(*)
FROM servers s, serv_inst i
WHERE s.srvr_id = i.srvr_id
AND s.srvr_id = 502
GROUP BY s.srvr_idi.installstatus;

SELECT * FROM TABLE(dbms_xplan.display);

-- if the base table may be updated then
ALTER SESSION SET query_rewrite_integrity = STALE_TOLERATED;