Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
BI Publihser Interview

BI Publihser Interview

Ratings: (0)|Views: 150|Likes:
Published by rambabujampani

More info:

Published by: rambabujampani on Mar 25, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less





PL/SQL support within Data Template separate the data extraction logic and XML generation intwo separate layers. We can hook the PL/SQL logic to implement the Business rules, Dataextraction or post processing logic. Through PL/SQL logic, we can push some of the complexdata calculation and network intensive operations to Database layer.Let's discuss following sample Data Template. The data template has associated default plsqlpackage.
Default PL/SQL Package (emp_test1.pls)
CREATE OR REPLACE package emp_test1 asDYNAMIC_WHERE_CLAUSE varchar2(3200);P_DEPTNO varchar2(10);P_SAL number;P_HIRE_DATE date;function BeforeReportTrigger return boolean;function DeptGroupFilter (p_dept_number number ) return boolean;function AfterReportTrigger (totalOrgsal number) return boolean;END;/CREATE OR REPLACEPACKAGE BODY emp_test1 ASfunction BeforeReportTrigger return boolean ISbeginIF (P_DEPTNO ='10') THENDYNAMIC_WHERE_CLAUSE :='D.DEPTNO =10';ELSIF (P_DEPTNO ='20') THENDYNAMIC_WHERE_CLAUSE :='D.DEPTNO =20';ELSIF (P_DEPTNO ='30') THENDYNAMIC_WHERE_CLAUSE :='D.DEPTNO =30';ELSIF (P_DEPTNO ='40') THENDYNAMIC_WHERE_CLAUSE :='D.DEPTNO =40';ELSEDYNAMIC_WHERE_CLAUSE :='1=1';END IF;return true;end;FUNCTION AfterReportTrigger (totalOrgsal number) return boolean ISBEGININSERT INTO org_sal (report_date,total_sal_amount ) VALUES (sysdate,totalOrgsal);commit;return true;END;
FUNCTION DeptGroupFilter (p_dept_number number) return boolean isBEGINIF (p_dept_number='30') THENRETURN FALSE;END IF;RETURN TRUE;end;END;/
PL/SQL logic should be implemented as single PL/SQL Package with following conditions.
All the parameters define in Parameter section of Data Template should be define asparameters in plsql package.2.
PL/SQL logic should be implemented as function and must return a Boolean value.3.
The package should be define as defaultPackage attribute in Data Template Header.In the above example, we see following three instance of PL/SQL call. Two dataTriggers andone Group Filter -<dataTrigger name="afterReport"source="emp_test1.AfterReportTrigger(:ORG_TOTAL_SALARY)" />-<dataTrigger name="beforeReport" source="emp_test1.BeforeReportTrigger" />1) Before Report Trigger The position of first dataTrigger is before the dataStructure section in Data Template. It gets firebefore the very first SQL query executes. In this example, PL/SQL function
drive the
variable based on
value. P_DEPTNO value will be available within plsql package as the process setthe value from data template parameters to pl/sql parameters. That is the reason; we need todefine the same set of parameters in PL/SQL as defined in data template. BeforeReportTrigger function set the DYNAMIC_WHERE_CLAUSE parameter calue as ³D.DEPTNO =10´. Beforeexecuting the SQL query Q1, process replace the substitute variableDYNAMIC_WHERE_CLAUSE with the actual values and following query get fired.SELECT d.DEPTNO,d.DNAME,d.LOC,EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM from DEPT D, EMP E whereD.DEPTNO=E.DEPTNOand D.DEPTNO =10PL/SQL parameter/s can be reference as substitute variables within SQL query and this featureallow us to design the dynamic SQL query based on the input parameters.
 The before report triggers can be used to designing dynamic SQL queries or filter conditionsusing substitute variables,populating the temporary or global temporary tables for Oracle appsfor complex data extraction process and then write the SQL query against these temp tables.2) After Report Trigger The position of ³afterReport´ data trigger is after the dataStructure section and termed as after Report Trigger. These triggers get fire after the XML generation complete. In our examplefunction ³AfterReportTrigger´ accept the ORG_TOTAL_SALARY as input parameter andinsert a record to ORG_SAL table.The purpose of after report triggers is to implement any post process logic as cleaning or deletingthe temp tables or records, auditing activities.3) Group Filter The use of Group filter is to filter out the groups from the XML ouput, if the specified conditionimplemented in calling function does not match. If the PL/SQL function returns the false, theparticular instance of group will not be the part of XML output.In the example, DeptGroupFilter accept the dept_number element value as input. If the value is30, it returns false and Group belongs to deptn0=30 will not be there in final xml.I tried multiple before and aft er data triggers within the same data template and they executedsequentially, So I think we can use multiple before and after dataTriggers. All these three callare simple PL/SQL functions and designed for some specific operations but there is norestrictions on nature of PL/SQL logic inside the function, just make sure it return theappropriate Boolean value.Please feel free to ask any question on this topic and I will be happy to help you out.
lobal Temporary Tables
Applications often use some form of temporary data store for processes that are to complicatedto complete in a single pass. Often, these temporary stores are defined as database tables or PL/SQL tables. In Oracle 8i, the maintenance and management of temporary tables can bedelegated to the server by using Global Temporary Tables.
Creation of Temporary Global Tables 
Miscellaneous Features 

Activity (6)

You've already reviewed this. Edit your review.
1 hundred reads
Raj Aryan liked this
TEJASKO liked this
TEJASKO liked this
TEJASKO liked this
TEJASKO liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->