Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Version 1.0
1 of 43
TABLE OF CONTENTS
Revision History ..........................................................................................................................................................4
Objective .....................................................................................................................................................................5
Guiding Principles .......................................................................................................................................................5
Development Deliverables ..........................................................................................................................................7
The Development Environment ..................................................................................................................................8
Customization/Enhancement Approach ............................................................................................................................... 8
Unix Host Environment ....................................................................................................................................................... 8
Custom Database Schemas .................................................................................................................................................. 9
Custom Tables ..................................................................................................................................................................... 9
Custom Packages and Triggers4 .......................................................................................................................................... 9
Registering Custom Programs ............................................................................................................................................. 9
Customized Code and Objects Registering ........................................................................................................................ 10
Fusion Middleware Development .............................................................................. Error! Bookmark not defined.
Oracle – B2B ....................................................................................................................... Error! Bookmark not defined.
SOA BPEL Process .............................................................................................................. Error! Bookmark not defined.
BAM Reports/Alerts ............................................................................................................. Error! Bookmark not defined.
Interface Development using VGT Interface Framework ........................................................................................ 11
VGT Interface Framework ................................................................................................................................................. 11
Visual Source Safe .................................................................................................................................................. 11
Naming Standards for VGT Custom application ..................................................................................................... 13
File – Code ........................................................................................................................................................................ 13
File – Data ......................................................................................................................................................................... 15
Database Object ................................................................................................................................................................ 15
Workflow Objects ............................................................................................................................................................... 17
AOL Object ........................................................................................................................................................................ 18
Database Objects Creation Standards .................................................................................................................... 19
Tables................................................................................................................................................................................. 19
Views .................................................................................................................................................................................. 21
Packages/Procedures/Functions........................................................................................................................................ 21
Programming Standards .......................................................................................................................................... 22
PL/SQL .............................................................................................................................................................................. 22
Oracle Forms ..................................................................................................................................................................... 25
Oracle Reports ................................................................................................................................................................... 25
SQL*Loader....................................................................................................................................................................... 26
Shell programs ................................................................................................................................................................... 27
Program Headers & Installation scripts ........................................................................................................................... 28
General Guidelines .................................................................................................................................................. 30
Date Format....................................................................................................................................................................... 30
Utilities to Debug, Trace and Tune & other tips ............................................................................................................... 30
Maintenance / Upgrades .................................................................................................................................................... 30
Guidelines for Conversions/Interfaces..................................................................................................................... 31
Conversions ....................................................................................................................................................................... 31
Interfaces ........................................................................................................................................................................... 31
Version 2.0 Created by VGT for VGT, For internal use only
2 of 43
Technical Turnover Document
SQL PERFORMANCE AND TUNING .......................................................................................................................................... 32
Objective: ........................................................................................................................................................................... 32
Access/Security Requirements: .......................................................................................................................................... 32
Steps to prepare performance statistics document: ........................................................................................................... 32
Development Guidelines for Efficient SQL and programs: ............................................................................................... 40
Tips for Efficient SQL and programs:................................................................................................................................ 40
Version 1.0
3 of 43
Technical Turnover Document
Revision History
Document Modifications
Version 1.0
4 of 43
Technical Turnover Document
Objective
The objective of this document is to provide development standards to generate and maintain source
code. Please note that though this and the following sections focuses more on development for Oracle
Applications.
By adopting this method VGTwill achieve the following:
1. Standardization on source code development within VGT.
2. Ease in maintenance of source code
3. Ease in Quality Assurance
4. Insure that modifications meet the users' requirements
5. Complete and easily understood documentation
6. Facilitate the transfer of responsibility for code maintenance to the VGTinternal technical support staff
Guiding Principles
Functional changes should not involve modification of ‘off-the-shelf’ code
Functional changes to Oracle Applications should never change core functionality. The standard
functions built into the software should always remain unchanged. If a standard form or report must be
modified, it should be copied to the custom application directory, modified, and then registered under the
custom application. The menu should then be modified to call the new version of the form or report. The
original program should remain in its original location.
A DBA/Developer other than the code developer will do the code reviews and standards for any of the
modifications. Before the customization is considered complete, users are required to retest the
modification after installation.
1Customization – any direct modification to standard Oracle code. VGT objective is to not perform any
customizations.
Version 1.0
5 of 43
Technical Turnover Document
Version 1.0
6 of 43
Development Deliverables
Development
Design Reviews Code Reviews
Standards
Check in Code
Requirement
Deliverables
Reviews
Unit Test & Results
Technical
Specification
String Test
Functional
High Level Design Installation
Specification
Instructions
Migration Package
Defect Fixes
Design Development
Test
User Procedures
Project Requirements Implementation Maintenance
Selection
Requirements Development Process
Processes
Version 2.0 Created by VGT for VGT, For internal use only
7 of 43
Technical Turnover Document
Customization/Enhancement Approach
One custom application top $XXVGT_TOP will be created for customizations to all modules. Code in standard
application directories may not be modified
Directories
Table 1 lists the directories that will be created under the XXVGT_TOP directory and the types of files that will be
stored in each.
Directory Contents
Name
Custom Tables4
New tables required by custom programs should be created in an Oracle user created exclusively for
customizations. For convenience, it should match the application short name of your custom application
(XXVGT). Grants and synonyms will allow other Oracle users to access your custom tables. To access
custom forms exclusively, you must register the custom Oracle ID ‘XXVGT’ in the Application Object
Library. If custom forms will be accessed from responsibilities that also access standard forms, simply
create grants and synonyms so that the Oracle user associated with the responsibility can access the
custom tables.
4 Custom tables and packages and triggers can be setup by the development team in the development
environment. If you need assistance setting this up in a development environment contact your friendly DBA.
Installation scripts will need to be written and reviewed by Applications Lead in order to migrate to a test
environment.
Version 2.0 For internal use only
9 of 43
Technical Turnover Document
3. After creating the custom function, a new Menu Item needs to be defined for the function.
Responsibility- Application Developer=>Application=>Menu
Procedure:
All custom objects should be moved to the custom $XXVGT_TOPdirectory. There are sub-directories for
all of the object types.
All custom objects i.e. tables, database packages, triggers, menus, reports, forms, views, and sequences
should be registered under VGTCustom Applicationapplication name. This is done for Database and
Form objects through the Application Developer Responsibility.
Custom reports will appear in the Application in the same screen as the” Standard” reports, but the code
will reside in $XXVGT_TOPdirectory. When an existing standard report requires modification, a clone of
the report should be made and the name of the report should be included in the custom report name (see
example below. The new report should then be renamed with a VGT- naming convention. The VGTtitle
will help identify the report as custom report.
For example, if a standard report INVIDITM.rdf. The new custom report will be
XXVGT_INVIDITM_<DESCRIPTION>.rdf.
Directory Contents
Name
FSD
install Installation/migration scripts
Concurrent Concurrent Programs Schedule
Programs
Schedule
Patch/115/imp All the LDT files including the WFT files except the JTF Grid ldts
ort/ XX
Patch/115/jtfgri All the JTF Grid Ldts
d
Patch/115/odf Table, Sequence, Synonym and Index scripts
Patch/115/sql All the custom views, package spec, package body,procedures, any
miscellaneous functions.
Patch/115/form Custom Forms (XX is the language code)
s/XX5
Patch/115/repo Custom Oracle Developer Reports (XX is the language code)
rts/XX
Patch/115/publ All the XML Publisher code like RTF templates, Data XML templates
isher and Bursting control files
Patch/115/sub All the Business event subscriptions
scriptions
Patch/115/spe Functional Specs along with the Technical Specs
cs
Directory Contents
Name
Custom
Extension:
6<COPIED OBJECT> should be used for objects that are copies of standard Oracle objects. Objects that are not
copied will not contain this parameter in the naming convention.
Version 2.0 For internal use only
14 of 43
Technical Turnover Document
File – Data
In the file name (except the extension) wherever English alphabet letters are used they should be in
UPPERCASE.
File Name should not contain any special characters i.e. “ ”, -, $, %, #, @, * and others.
Database Object
A database schema can be composed of various objects i.e. tables, indexes, sequences, views,
synonyms, procedures, triggers, packages and functions and database links. Please ensure the following
naming convention is followed.
Object name can be a maximum of 30 characters long, ideally no more than 15 to 20 characters. The
name should start with XXVGT_The naming convention should facilitate in distinguishing the objects.
The norm to adopt is as follows
Table XXVGT_COPIEDOBJECT_DE
SCRIPTION
y=”U” Update
“I” Insert
“D” Delete
z=”S” Statement
“R” Row
n =Sequence Number
Object name should not contain any special characters i.e. “ ”, -, $, %, #, @, * and others.
Object name should be unique within the namespace or schema.
Object name nomenclature should be self explanatory, having a meaningful name that is understandable by
the end users and IS groups
Workflow Objects
In order to isolate custom objects (Item Types, Item attributes, lookup types etc.) within a workflow, it is important
to have a naming standard for workflow objects too.
AOL Object
Concurrent Program 30 Short name of the Keep the same name as the
executable – Short Name Characters concurrent program executable.
executable
Tables
The sequential order in which the columns need to be defined are:-
Primary key columns
Unique key column
Mandatory columns
Optional columns
Long field column
WHO columns
Ensure that the WHO columns (CREATED_BY, CREATION_DATE, LAST_UPDATED_BY, UPDATE_DATE)
exist.
Ensure that columns to flag error messages (PROCESSED_FLAG) exist in cases where there is an interface
requirement.
Following are the possible values of processed_flag we will use, to signify what it means:
The interfaces might have different values than the ones mentioned above which will be explained in
the technical document for that interface.
All in all, ensure that the following columns exist as below.
Tables
Table Dos
Columns
3. Use the following data types to qualify a column in a table VARCHAR2, NUMBER, DATE,
BOOLEAN etc.
4. If the data to be stored in the table is partitioned on the Operating unit then an ORG_ID column
with the default definition must exist. Similarly, if the data to be stored in the table is portioned on
the inventory organization, then an ORGANIZATION_ID must exist.
5. Ensure that the columns are classified as NULL or NOT NULL. By default the column definition is
NULL.
6. Use the constraint/default definitions and referential integrity definitions for the columns of the table
Names
7. Whenever appropriate qualify the table name to denote it’s purpose i.e. 1)_STG (Table that holds
data before been sent out of Apps to other subscribing applications. Table that holds data before
been pushed into the open interface tables for data conversion purposes). 2) _TEMP (Table that
holds temporary data for calculation, any further processing. A table that holds the data after the
initial load from a flat file, which has a combined record, based on multiple tables. For e.g. Vendor
and vendor site records could come in a single record in the flat file and it will be convenient to hold
them in an initial TEMP table before splitting them into multiple STG tables)
8. Register custom tables using AD_DD package, if it needs to be used by Application Object Library
Table Don’ts
General
9. Do not specify storage clause when you create the table unless it is specially required. Only
specify the tablespace name. The table will derive the defaults from the tablespace.
Columns
10. Avoid using Long, if your column length is within 4000 characters. Use Varchar2(4000) instead
11. Do not create columns of type LONG or Long Raw. Use BLOB/CLOB instead
Views
View on a partitioned table needs to be created in the “APPS” schema. Use the WHERE CLAUSE within the view
definition to dynamically partition the data on user access.
Dos
1. Include the ROWID pseudo column of the root table of the select statement as the first
column of the view aliased to “ROWID”
2. If a form is going to use the view as the “base table”, include each column of the foreign
key tables likely to be displayed and/or manipulated by a form into the view.
Packages/Procedures/Functions
Dos
1. Define packages and procedures as far as possible against SQL scripts. You would only use
sql scripts for anything one-off
2. The package specification and body will be in separate files with extension “pks”, “pkb”.
3. If the custom package is based out of a standard package, make sure the changes that are
done are well commented. It needs to be in the following format
/* VGTCustomizations begin */
/* <sysdate> */
Don’ts
General
Programming Standards
PL/SQL
Dos
General
1. The PL/SQL packages or code written in 3GL must be modular and structured.
2. The PL/SQL design to take into account how to re-commence a terminated job, and not re-
process the processed records unless there is an explicit requirement.
5. If the PLSQL is based out of a standard PLSQL package, make sure the changes that are
done are well commented. It needs to be in the following format
/* VGTCustomizations begin */
/* <sysdate> */
/* Comments …..*/
/* VGTCustomizations end */
SQL Statements
7. Your INSERT statement needs to specify the fields and values. Only one field can be on one
line and only one value can be on one line.
INSERT INTO TABLE table_name
(field1,
field2,
field3)
VALUES
(value1, --field1
value2, --field2
value3); --field3
Cursors
8. Wherever possible use FOR Record in Cursor LOOP rather than OPEN CURSOR statement
9. Cursor to refer to object name(s) on which it is defined and to be initcap. Cursor to be prefixed
with ‘Cur’
Variables/ Parameters
All PL/SQL procedure/function parameters will be prefixed with ‘P_’ so that there is no
10. possibility of conflicts with database object names or confusion as to which are PL/SQL
variables and which are database objects. It will also avoid confusion between local variables
and parameters.
Example: P_header_id
All PL/SQL variables will be prefixed with ‘X_’.
11. Example: X_header_id
All PL/SQL constants will be prefixed with ‘C_’ Example: C_record_count
12.
All PL/SQL Global variables will be prefixed with ‘G_’ to distinguish global variables from local
13. variables.
Procedure Calls
15. Invoke a procedure by passing parameter name and associated parameter value
VALIDATE (P_ORG=> X_ORG, P_SOB=> X_SOB)
Exception Handling
16. Ensure that at least the following exception are handled in the PL/SQL constructs
NO_DATA_FOUND
TOO_MANY_ROWS
OTHERS
Don’ts
General
18. Do not include explicit commits within the package. In case the package requires processing
of records that can create rollback segment problem, please put commits at logical transaction
points with SAVEPOINT and ROLLBACK functions.
Triggers
20. Avoid triggers that duplicate the functionality already built in Oracle (example enforce data
integrity by using declarative integrity constraints rather than a DB trigger)
21. Within a trigger DDL statements are not allowed. Also no transaction control statements are
allowed in a trigger (ROLLBACK, SAVEPOINT, COMMIT)
22. Do not have trigger with greater than 60 lines of code. Create PL/sql package instead and call
it from the trigger.
23. SQL statements in a trigger body may not read from or modify (DML) any table of the triggering
statement. This includes the triggering table itself. This will cause “mutating table” error.
24. SQL statements in a trigger body may not read from or modify the primary, unique or foreign
key column of a constraining table of the triggering table.
SQL Statements
25. Do not create insert statements without column names. For e.g. Do not specify the insert
statement in the following way:
INSERT INTO TABLE
VALUES
26. Do not have insert statement with all fields in one line. For e.g. do not write your insert
statement the following way
INSERT INTO TABLE table_name (field1, field2, field3, field4)
Values
(value1, value2, value3,value4)
27. Do not invoke a procedure by passing just parameter values. Do not call the procedure the
following way: VALIDATE (X_ORG,X_SOB)
Oracle Forms
Dos
6. If the custom form is based out of a standard form, make sure the changes that are done are
well commented. It needs to be in the following format
/* VGTCustomizations begin */
/* <sysdate> */
/* Comments …..*/
/*VGTCustomizations end */
Don’ts
7. Do not modify standard forms. Determine the use of custom.pll before customizing forms
Oracle Reports
Dos
General
1. Unit Test BOTH report display and printing from within the Oracle Applications Framework
2. Instead of writing extensive logic within the report, write a PL/SQL Package and call it within
the report. The advantage is maintenance becomes simple and other programs may use the
same routine.
5. If the custom report is based out of a standard report, make sure the changes that are done
are well commented. It needs to be in the following format
Triggers7
Don’ts
General
7. Do not just test report display and printing from Developer tools. The report output from
developer tools will be VASTLY different to the output from Oracle Applications framework.
Triggers
9. No logic must exist in the After Parameter form. If the logic exists, then move it to the BEFORE
REPORT TRIGGER. The logic should be incorporated after the call to SRWINIT function.
This encapsulates all code in one place.
SQL*Loader
The basic SQLLOAD command is
SQLLOAD or SQLLDR
USERID = Oracle Username/password
CONTROL = Control file name
LOG = Log file name
BAD = Bad file name
DATA = Data file name
DISCARD = Discard file name
DISCARDMAX = Number of discard allowed – default is ‘ALL’
SKIP = Number of records to skip – default is 0
LOAD = Number of records to load – default is ‘ALL’
ERRORS = Number of errors allowed – default is 50
7 Triggers and alerts can be setup by the development team in the development environment. If you need
assistance setting this up in a development environment contact your friendly DBA. Installation scripts will need
to be written and reviewed by DBA in order to migrate to a test environment.
Dos
SQLLOAD Command
1. Default # of error records = 50. Set the value to a high value, otherwise processing would stop
once error record reach 50
2. Make sure the log, bad and data options have proper file names with full directory path so that
these files are generated in the correct directory.
3. If the data file is comma delimited, make sure you have the optionally enclosed by ‘”’
statement. This will ensure that the comma will not be treated as a delimiter, whenever comma
is part of a description column. It does need to be ensured that description is enclosed by “ –
double quote. By default, Microsoft Excel encloses Text field with “ when you create a csv file
from a XLS file whenever comma is part of the text field.
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
CTL file
Don’ts
SQLLOAD Command
CTL File
7. Do not use “Constant NULL“ to assign null to a column. To set a column to NULL do not
specify the column
Shell programs
Dos
1. All shell programs for ftp-ing files, loading data etc., must be run under the framework of Oracle
applications. It needs to be registered as a concurrent program and executed as one. Our
standard is to run all shell programs as concurrent programs so they can managed centrally.
2. Make the following command part of the first statement in the file
#!/bin/ksh. This is so that the shell will execute as a Korn shell.
Korn shell is a super set of bourne shell. Ksh has the best features of both C shell and Bourne
shell and many features of its own. You can write programs to run faster with ksh than with
either Bourne or c shell.
3. All shell scripts must have a .ksh extension except oracle concurrent programs that are
executed as shell programs.
Dos
1. Make sure there is a header for every program and follows the following example
2. Every installation script must have enough comments to call out what it is doing
3. Every installation script must create a log file to call out what was performed as part of the
installation.
4. Make sure the installation script has “set echo on” and “set feedback on” to display the SQL
that is been executed and to display the results of the SQL command
6. Do not specify DROP statements in any scripts. If a table, sequence or an index needs to be
dropped or changed, the DBA group needs to be notified about the change because they want
to evaluate any impacts of drop table statements and changes to table indexes.
7. Use the CREATE OR REPLACE syntax whenever possible. (This includes synonym, package
specification, package body, view, and database trigger scripts).
EXAMPLE:
Original Author:
Notes:
History:
=======================================================================
| DATE | Author | Activity
=======================================================================
| DD-MON-YY | Venkat P | Created initial script.
|
|
|
=======================================================================
*/
Installation Scripts
PROMPT ******************************************************
PROMPT Creating sequence...
PROMPT ******************************************************
CREATE SEQUENCE statement;
PROMPT ******************************************************
PROMPT Inserting records into table_name
PROMPT ******************************************************
DEFINE dflt_user_id = -1
DEFINE dflt_date = "'DD-MON-RRRR'"
DEFINE dflt_login = NULL
PROMPT ******************************************************
PROMPT Create Grants ...
PROMPT ******************************************************
GRANT statement;
PROMPT ******************************************************
PROMPT Create DB Links ...
PROMPT ******************************************************
Create DB Link statement;
PROMPT ******************************************************
PROMPT Create synonyms ...
PROMPT ******************************************************
CREATE OR REPLACE SYNONYM statement;
Version 2.0 For internal use only
29 of 43
Technical Turnover Document
PROMPT ******************************************************
PROMPT Create views ...
PROMPT ******************************************************
CREATE ORE REPLACE VIEW statement;
PROMPT ******************************************************
PROMPT Creating package procedure ...
PROMPT ******************************************************
CREATE OR REPLACE PACKAGE PROCEDURE Statement
General Guidelines
Date Format
Ensure that the input date format conforms to DD-MON-RRRR format on the forms, reports, PL/SQL
packages, SQL and loader scripts. If there are space constraints on the report or constraints placed by
legacy systems in extracting the data in this format, then you could use DD-MON-RR
If dates are stored in character columns, use a pre-defined format ‘RRRRMMDDHH24MISS’. These
definitions may be in the value set definitions, flexfield definitions, and others.
Avoid string conversion issues by using the DATE data type. If conversion is required, then explicitly
convert into a pre-defined format of ‘RRRRMMDDHH24MISS’. Do not perform implicit conversion - as the
format may be governed by the NLS_DATE_FORMAT.
Maintenance / Upgrades
If a component (Form/Report/Procedure..) requires changes due to change in the scope, then the approval
and review process has to be followed again for the Requirements document and the Design document.
Software configuration and revision control tools (e.g., PVCS) are required for storing the various versions
of the components.
Migration tools when available will be used (e.g., Kintana for Oracle Apps) for moving the components
across various instances (e.g., from development instance to the testing instance).
Version 2.0 For internal use only
30 of 43
Technical Turnover Document
Interfaces
Please refer to the Interface Standards and Guidelines, as well as the Oracle developer Application Standards
document
Objective:
One of the most important challenges faced by oracle developers and administrators is the need to tune SQL
statements. Poorly designed applications can cause issues like 1.excessive CPU consumption (too many
logical I/Os), 2.excessive disk reads as a result of missing indexes 3.excessive contention for shared
resources.
This section of the standards document lays out the guidelines to be followed to identify and avoid poor
performing SQL’s as well as some tips to be followed to write optimal SQL based programs.
Access/Security Requirements:
1. Developer database accounts should have full access to table PLAN_TABLE in development instances.
2. Developer database account should have ALTER SESSION privileges so that they can run following
command
ALTER SESSION SET sql_trace=TRUE
3. Developer UNIX accounts should have privileges to run 'tkprof' utility on development UNIX servers.
4. Developers UNIX accounts should have read access to the directory and trace files on development
UNIX servers.
a. Following are the steps that will help in generation of trace files for various types of programs.
i. If it is a concurrent program (Report / PL SQL Interface), go to the concurrent program
definition screen and check the ‘Enable Trace’ check box. This will generate the trace file
in the user dump directory each time this concurrent program is run (please uncheck the
option enable trace before the concurrent program is migrated to other environments).
Run the concurrent program and use the Request ID in the following SQL statement to
identify the trace file details.
SELECT 'Request id: '||request_id ,
'Trace id: '||oracle_Process_id,
'Trace Flag: '||req.enable_trace,
'Trace Name:
'||dest.value||'/'||lower(dbnm.value)||'_ora_'||oracle_process_id||'.trc'
TRACE_FILE_NAME,
'Prog. Name: '||prog.user_concurrent_program_name,
'File Name: '||execname.execution_file_name|| execname.subroutine_name ,
'Status : '||decode(phase_code,'R','Running')
||'-'||decode(status_code,'R','Normal'),
'SID Serial: '||ses.sid||','|| ses.serial#,
'Module : '||ses.module
from fnd_concurrent_requestsreq, v$sessionses, v$processproc,
v$parameterdest, v$parameterdbnm, fnd_concurrent_programs_vlprog,
fnd_executablesexecname
where 1=1
Version 2.0 For internal use only
33 of 43
Technical Turnover Document
and req.request_id = :request
and req.oracle_process_id=proc.spid(+)
and proc.addr = ses.paddr(+)
and dest.name='user_dump_dest'
and dbnm.name='db_name'
and req.concurrent_program_id = prog.concurrent_program_id
and req.program_application_id = prog.application_id
and prog.application_id = execname.application_id
and prog.executable_id=execname.executable_id;
ii. To generate a trace file for a PL/SQL block that is not a concurrent program please follow
the below steps.
1. Navigate to corresponding oracle form and set the ‘Trace with bind’ option by
going to Help Diagnostics Trace Trace with Binds.
2. The trace file name and location will be displayed on the screen.
iv. Location and name of the trace file is displayed on the screen
b. Run tkprof against the trace file to generate a tkprof file. Tkprof command should be executed
from Unix command prompt. Use telnet or putty to login to unix box and run following command:
tkprof<input_file><output_file> sort=fchqry
2. For all poor performing SQL’s identified in tkprof, and for any stand alone SQL’s (Discoverer) do the
explain plan exercise. Two key metrics that are used for evaluating the performance of a SQL statement
are the explain plan and the number of consistent gets.
A SQL query is returning more than 40% of the rows from a particular table.
A table has less than 1000 rows.
The following outlines the steps required to obtain the information using TOAD.
Prerequisite: Make sure plan table is created in your schema or have privileges on it.
Step 1 – Open TOAD
Step 2 – Enable AutoTrace
1. Right click on the SQL Editor window and select “AutoTrace” or click on the Auto Trace tab, and
answer ‘Yes’ to enable it.
Step 3 – Execute SQL Statement
1. Type SQL Statement in edit field (Illustrated in Figure 1)
2. Execute SQL Statement
Copy and paste sql statement, explain plan info, and trace info into the ‘xxx.xx Rice Description PS.Doc’
3. For summarizations, use incremental approach instead of summarizing everything for each run.
4. Avoid using ‘Like’ on predicates of a where clause if possible. Use =’explicit value’
5. Avoid using functions on the predicates of a where clause. If you have to use a function, create a function
based index.
7. All index creation statements should include following clauses: (I think DBA’s do this on a regular basis)
i. Analyze compute
ii. Parallel degree 4
iii. Tablespace CASX
9. For your interfaces or complex reports you may be using staging tables. Typically a complex oracle report
would be populating an intermediate table via PL/SQL procedure call, and layout will be built based on a
simple sql on top of that intermediate table. Or, you may be populating data into staging table first and
then populate into main table after further validation. Consider following in sequence for options:
Evaluate usage of Global temporary tables. Global temporary tables are
great alternative for staging or intermediate tables. The data in these tables
is private to the session..
c. If Global temporary tables is not an option and you need to create a staging table, then do
following:
i. Purge all temp tables at the end of program.
ii. Use truncate instead of delete.
iii. If truncate is not an option, delete rows in batches.
1. Use DECODE when you want to scan same rows repetitively or join the same table repetitively.
Example:
--------
2. Always use table alias and prefix all column names with the aliases when you are using more than one table.
In sub-query statement such as the following NOT IN clause causes an internal Sort/Merge.
SELECT *
FROM emp e
WHERE e.deptno NOT IN ( SELECT d.deptno
FROM dept d
WHERE d.dname like %S% ) ;
SELECT *
FROM emp e
WHERE NOT EXISTS ( SELECT d.deptno
FROM dept d
WHERE d.deptno = e.deptno
AND d.dname LIKE '%S%' ) ;
SELECT *
FROM emp e
WHERE EXISTS ( SELECT d.deptno
FROM dept d
WHERE e.deptno = d.deptno
AND d.dname = 'RESEARCH') ;
Use EXISTS in place of DISTINCT if you want the result set to contain distinct values while joining tables.
SELECT d.deptno ,
d.dname
FROM dept d
WHERE EXISTS ( SELECT e.deptno
FROM emp e
WHERE d.deptno = e.deptno ) ;
6. Never use NOT on an indexed column. Whenever Oracle encounters a NOT on an index column, it will
perform full-table scan.
SELECT *
FROM emp
WHERE NOT deptno = 0;
SELECT *
FROM emp
WHERE deptno> 0;
7. Never use a function / calculation on an indexed column. If there is any function is used on an index column,
optimizer will not use index. Use some other alternative. If your evaluation demands to use functions, then create
function based indexes.
Examples:
SELECT *
FROM emp
WHERE SUBSTR(ENAME,1,3) = 'MIL' ;
SELECT *
FROM emp
WHERE ENAME LIKE 'MIL%' ;
SELECT *
FROM emp
WHERE sal != 0 ;
SELECT *
FROM emp
WHERE sal> 0 ;
SELECT *
FROM emp
WHERE ename || job = 'MILLERCLERK' ;
SELECT *
FROM emp
WHERE ename = 'MILLER'
AND job = 'CLERK' ;
SELECT *
FROM emp
WHERE sal*12 > 24000 ;
SELECT *
FROM emp
WHERE sal> 24000/12 ;