Thursday, April 22, 2010

Table Partitioning


Every data’s should be stored in database, because world can’t run without storing the data’s in the database. Machinery world should store data’s in database for future reference and process, so the database will be filled up of data’s. The records will be more and more and the size of the data might be Tera bytes of ranges. These databases are known as Very Large Databases (VLDB). Oracle has provided the feature of table partitioning i.e. we can partition a table according to some criteria.

For example we have an EMPLOYEE table with the following structure
Suppose this table contains millions of records, but all the records belong to four years only i.e. 2007, 2008, 2009 and 2010.

And most of the time we are concerned about only one or two years i.e. we give queries like the following

select sum(salary) from sales where year=1991;
select empName,sum(salary) from sales where year=1992
Group by empName;

Now whenever you give queries like this Oracle will search the whole table. If you partition this table according to year, then the performance is improve since oracle will scan only a single partition instead of whole table.


CREATING PARTITION TABLES

To create a partition table gives the following statement

create table employee(empid number(4),
empName varchar2(10),
salary number(10,2))
partition by range (year)
partition p1 values less than (2007) tablespace u1,
partition p2 values less than (2008) tablespace u2,
partition p3 values less than (2009) tablespace u3,
partition p4 values less than (2010) tablespace u4,
partition p5 values less than (MAXVALUE) tablespace u5;

In the above example employee table is created with 5 partitions. Partition p1 will contain rows of year 2007 and it will be stored in tablespace u1.

Partition p2 will contain rows of year 2008 and it will be stored in tablespace u2.
Similarly p3 and p4.

In the above example if we don’t specify the partition p4 with values less than MAXVALUE, then we will not be able to insert any row with year above 2010.

Although not required, we can place partitions in different tablespaces. If we place partitions in different tablespaces then we can isolate problems due to failures as only a particular partition will not be available and rest of the partitions will still be available.

The above example the table is partition by range.

In Oracle we can partition a table by using the following partition methods,
  • Range Partitioning
  • Hash Partitioning
  • List Partitioning
  • Composite Partitioning

ALTERING PARTITION TABLES
To add a partition

we can add a new partition to the "high" end (the point after the last existing partition). To add a partition at the beginning or in the middle of a table, use the SPLIT PARTITION clause.

For example to add a partition to employee table give the following command.

alter table employee add partition p6 values less than (2008);

To add a partition to a Hash Partition table give the following command.

Alter table employee add partition;

Then Oracle adds a new partition whose name is system generated and it is created in the default tablespace.

To add a partition by user define name and in your specified tablespace give the following command.

Alter table employee add partition p5 tablespace u5;

To add a partition to a List partition table give the following command.

alter table employee add partition empName
values (‘JONES’,’SMITH’);

Any value in the set of literal values that describe the partition(s) being added must not exist in any of the other partitions of the table.

Wednesday, April 21, 2010

BI Bursting

One of the very good features of Oracle BI Publisher is its ability to burst and send the reports to multiple users simultaneously.

Using BI Publisher's bursting feature we can split a single batch report into individual reports to be delivered to multiple destinations. We can apply a different template, output format, delivery method, and locale to each split segment of our report. Example implementations include:
  • Invoice generation and delivery based on customer-specific layouts and delivery preference
  • Financial reporting to generate a master report of all cost centers, bursting out individual cost center reports to the appropriate manager
  • Generation of pay slips to all employees based on one extract and delivered via e-mail

Enabling a Report for Bursting

Prerequisite: A report defined in BI Publisher. The report data must contain an element by which the report will be split and an element by which the report will be delivered.
Enabling a report for bursting consists of the following steps:
  • Open the report in Edit mode.
  • Select Bursting under the report definition.
  • Select the Enable Bursting check box.
  • Select the Split By and Deliver By elements.
The Split By element is the data element from the report file that you wish to split the report by. For example, to split a batch of invoices by each invoice, you may use an element called CUSTOMER_NAME.

The Deliver By element is the data element from the report file by which to determine the delivery method. In the invoice example, it is likely that each invoice will have delivery criteria determined by customer; therefore the Deliver By element may be CUSTOMER_ID.
  • Select the data source for the delivery XML.
The delivery XML can be sourced from the same data source as the main data set, or it can be generated from a different data source.
  • Enter the SQL query to build the delivery XML. See Defining the Delivery Data Set for details.
















Defining the Delivery Data Set

Based on the SQL query that we provide on the Bursting criteria page of the Report Editor, BI Publisher will build the delivery XML data set. The delivery XML data set contains the information to deliver the burst report appropriately to each recipient. The delivery data in this XML document is used as a mapping table for each Deliver By element. The structure of the delivery XML is as follows:
























Where
  • KEY is the Delivery key and must match the Deliver By element. The bursting engine uses the key to link delivery criteria to a specific section of the burst data.
  • TEMPLATE - is the name of the Layout template to apply. Note that the value is the Layout name (for example, "Invoice"), not the template file name (for example, invoice.rtf).
  • TEMPLATE_FORMAT - is the format of the layout template. Valid values are:
o RTF
o PDF
o ETEXT
o XSL_FO
  • LOCALE - is the template locale, for example, "en-US".
  • OUTPUT_FORMAT - is the output format. Valid values are: for example: pdf, html, excel.
o HTML
o PDF
o RTF
o EXCEL
  • DEL_CHANNEL - is the delivery method. Valid values are:
o EMAIL
o FAX
o FILE
o FTP
o PRINT
o WEBDAV
  • Delivery parameters by channel. The delivery parameters by channel are defined in the following table:

Parameter Mapping



















To put the Company logo in each APEX page



  • Go to Shared Components then click the images link and upload the image to application.
  • Click the Definition write the image name to logo text field as #WORKSPACE_IMAGES#company_logo.gif
  • Go to Page Template and add the LOGO prefix at table

Dynamically Generate the Checksum id to solve the apex vulnerability problem

Ajax(Application Process) used call the Oracle Query of APEX_ITEM.MD5_CHECKSUM
  • Java method of Math.random used to get Random no
  • Random no used to get the Attribute value from Select list
Example : thisObj = objs[rand_no];
if(thisObj){
checksumId=thisObj.getAttribute('value');
return checksumId;

--- Apex Generate the checksum id per day only one time, I have customized and generated the checksum id per each page refresh.

Here show the checksum id screenshot,




















Create Customize POPUP LOV for APEX



  • Javascript Used to Get the Tabular Form Id
Example : var eleTables = document.getElementsByTagName("table");
for (var i=1;i
var tId = eleTables[i].id;
if(tId.substring(0,7)!=''){
if(tId.substring(0,7)=='report_'){
var originalId = i;
var tableIds = eleTables[i].id;
tableId = tableIds;
return tableId;
} } }

  • Create the POPUP Image on tabular column
Example : var link = document.createElement('a');
var image = document.createElement('img');
var span = document.createElement('span');
link.setAttribute('href','javascript:genList0_f16_0("'+a1+'","'+filters+'")');
link.className="dark";
image.setAttribute('src','/i/list_gray.gif');
  • Customize the Window open
Examlpe : w = open("wwv_flow_utilities.gen_popup_list" +
"?p_filter=" +
"&p_name=" + escape(filters) + "&p_element_index=" + escape (a1) +
"&p_form_index=" + escape('0') + "&p_max_elements=" + escape('') +
"&p_escape_html=" + escape('') + "&p_ok_to_query=" + escape('YES') +
"&p_flow_id=" + escape(appId) + "&p_page_id=" + escape(pageId) +

"&p_session_id=" + escape(l_field) + "&p_eval_value=" + escape('') +
"&p_translation=" + escape('NO') + "&p_lov_checksum=Dynamicchecksum
"winLov", "Scrollbars=1,resizable=1,width=400,height=450");
if (w.opener == null) w.opener = self; w.focus();

Based on Custom POPUP(Head No Column) append the value to Select list(Product) and read only column(Description and Drawing No)
Here Return value(M2595) also customized then return to Tabular Column.
















Monday, April 19, 2010

Report Generation from BI through APEX



Oracle APEX is user friendly for designing part as well as client side data entry and validation related things.

Oracle BI Publisher is good for report output; it will give the output files like PDF, XLS etc, Very big advantage in BI Publisher is that can produce multiple output files as a report. With the option of Bursting.

Bursting will be scheduled with the particular time interval, or can schedule by the time as per the report need.

Template file is base for required output report. Because output will be produced based on the input template design.

In APEX, under Shared components there is an option called Report Layouts, that is getting the input template file for report designing.








That same navigation having the link called Report Queries, which is getting the query from user to generating report based on template and query.

When the user clicking on the designed button, then the Report file will be generated based on template and query.

The button option should be Download printable Report Query, and then only that printable option will work.













Apex used to call the Oracle JOB scheduler and Java



  • Create the html link on apex
  • Ajax(Application Process) used to call the DBMS_SCHEDULER then generate the job name
  • Ajax(Application Process) used to call the DBMS_SCHEDULER .CREATE_JOB then Execute the job name
Example :
select DBMS_SCHEDULER.GENERATE_JOB_NAME('hariharhomes') into jobnames from dual;
dbms_scheduler.create_job( job_name=>jobnames, job_type=>'executable',
job_action=>'/u01/app/oracle/product/10.2.0/ias/Apache/Apache/images/mani.sh', enabled=>TRUE );

Append the Data Base value to Tabular Form Select List


  • Ajax(Application Process) used to Get the value from Data base Return value as node and attribute.
Example : l_Opt_Xml.firstChild.nodeValue and l_Opt_Xml.getAttribute('value').
  • Create the Element of OPTION
Example : var l_Opt = document.createElement("option");
  • Add the OPTION to Target Select List and Append the OPTION to Target Select List
Example : pSelect.options.add(l_Opt); pSelect.appendChild(l_Opt);
  • Insert the select list content to OPTION and Append the select list content to OPTION
Example : l_Opt.innerText = pContent;
l_Opt.appendChild(document.createTextNode(pContent));

Friday, April 16, 2010

Configuring APEX to use BI Publisher


To use BI Publisher as your Report Server, first, access the Report Printing parameters:

Go to The following navigation in APEX with Admin credentials.
  1. Access the Administration Services home page
  2. Select Manage Service
  3. Select Instance Settings, under Manage Environment Settings
  4. Click Report Printing to focus on just the Report Printing attributes
Now, specify the following attributes:
  • Oracle BI Publisher: Advanced Support
  • Print Server Protocol: HTTP or HTTPS (depends on your configuration)
  • Print Server Host Address: the hostname for the machine where you installed BI Publisher - e.g. myhost.mycompany.com
  • Print Server Port: the port given at the end of the BI Publisher installation - e.g. 9704
  • Print Server Script: /xmlpserver/convert

Append the Data Base value to Tabular Form Read only Column


  • Get the interactive repot table id
Example : var apexform = $x{tableid};
  • Mention the rows and column
Example: var ApexTableId =filter.id; var row= ApexTableId.substring(4,8);
var newCell = ApexTableId.rows[row].cells[4];
newCell.innerHTML = Databasevalue;
  • Ajax(Application Process) used to get the value from Data Base then append into Table cell
output : In our project Product Description is Tabular Form Read only Column













Hide the Report Column based on User Condition


  • Get the interactive repot table id
Example : var apexform = $x{interactive report tableid};
  • Mention the rows and column
Example: var hidecell1= apexform.rows[4].cells[0];
  • Script used to hide the particular cell
Example: hidecell1.style.display='none';

Thursday, April 15, 2010

Apex Interactive Report Cosmetics


  • To Change the Report Field Title color
.apexir_WORKSHEET_DATA th div {font-size:12px; color:black; }

  • To draw border for the Report
table.apexir_WORKSHEET_DATA th div{text-decoration:none;}
table.apexir_WORKSHEET_DATA td, table.apexir_WORKSHEET_DATA th {border:1px solid darkblue}

  • To Give Background color for report and change the report font color
.apexir_WORKSHEET_DATA td {font-size:11px; color:DarkBlue;background-color:whitesmoke;}

The above code will print like white smoke as background color of report and text color of the report will be dark blue.

[The above codes should be written in HTML Header of the page, within the below tag]

<style>
</style>

Oracle BI Publisher Desktop


Making the relationship between Microsoft word and BI Publisher will be very convenient for template designing part. Because by using Microsoft word, user can draw the tables and they can do lots of designing parts.

To enable the BI Publisher tool bar in to Microsoft word, we need to install the plug-in.
To aid in the building of RTF templates BI Publisher provides the BI Publisher Template Builder for MSWord. Prior to starting the examples we should download this plug-in and install it. This is available from metalink; the latest version is 5.5 and can be found by downloading patch 4561835. Alternatively we can install from the BI Publisher window itself.








We can install by clicking on the Template Builder link in that above picture. After that the add-ons will be installed and BI Publisher menu will be enabled in Microsoft word document.









Add-Ins has enabled and displayed in word like the other options
Under the Add-Ins following tab has enabled.
  • Oracle BI Publisher
  • Data
  • Insert
  • Preview
  • Tools
  • Help

By using the above method to enable Oracle BI Publisher add-ins in Microsoft word.

Oracle BI Publisher Introduction


Oracle XML/BI Publisher is a very good reporting tool, which outputs reports into many formats like Word, Excel, PowerPoint, PDF and even to Adobe Flash. This can deliver reports generated from XML/BI Publisher to many destinations like email, fax and printer using the standard API’s.

Create a template to lay out the data in a report, and publish the report to numerous output formats. BI Publisher also enables to schedule reports and deliver the reports to any delivery channel required as per the business need.
A report consumer may perform the following tasks:
  • Run and view reports from the BI Publisher reports repository
  • Schedule reports to run at selected intervals and to be delivered via any channel set up by your administrator
  • Create an ad hoc analysis of report data using BI Publisher's Analyzer feature
  • Open and manipulate reports in Microsoft Excel using BI Publisher's Analyzer for Microsoft Excel
Process to generate the report
The report attributes, what needs to display should be stored in database table. We can select the values from table and display as a report as per input template.

Design the Template

Microsoft word is very useful to create the template for report designing. Design the template as per report need and add the database fields in the corresponding areas so that the report will be displayed in neat format.

Name
Job Title
Department Name
Salary
F Odd Row: NAME
JOB
DNAME
SAL
Even Row: NAME
JOB
DNAME
SAL E


TOTAL



(The template file should be stored as rich text format (rtf) file.)




Tuesday, March 9, 2010

Oracle Application Express 4.0 EA2

Oracle Application Express 4.0 Early Adopter Phase II (EA2) is now available.















Fill out the survey and request a NEW workspace on oracle's hosted instance @ http://tryapexnow.com