Friday, August 26, 2016

Oracle SQL Performance Tuning Common Tips

1. Do not use the set operator UNION if the objective can be achieved through an UNION ALL. UNION incurs an extra sort operation which can be avoided.
2. Select ONLY those columns in a query which are required. Extra columns which are not actually used, incur more I/O on the database and increase network traffic.
3. Do not use the keyword DISTINCT if the objective can be achieved otherwise. DISTINCT incurs an extra sort operation and therefore slows your queries down.
4. If it is required to use a composite index, try to use the “Leading” column in the “WHERE” clause. Though Index skip scan is possible, it incurs extra cost in creating virtual indexes and may not be always possible depending on the cardinality of the leading columns.
5. There should not be any Cartesian product in the query unless there is a definite requirement to do so. I know this is a silly point but we all have done this mistake at one point ðŸ™‚
6. Wherever multiple tables are used, always refer to a column by either using an alias or using the fully qualified name. Do not leave the guess work for Oracle.
7. SQL statements should be formatted consistently (e.g the keywords should be in CAPS only) to aid readability. Now, this is not a performance tip really. However, it’s important and part of the practices.
8. If possible use bind variables instead of constant/literal values in the predicate filter conditions to reduce repeated parsing of the same statement.
9. Use meaningful aliases for tables/views
10. When writing sub-queries make use of the EXISTS operator where possible as Oracle knows that once a match has been found it can stop and avoid a full table scan (it does a SEMI JOIN).
11. If the selective predicate is in the sub query, then use IN.
12. If the selective predicate is in the parent query, then use EXISTS.
13. Do not modify indexed columns with functions such as RTRIM, TO_CHAR, UPPER, TRUNC as this will prevent the optimizer from identifying the index. If possible perform the modification on the constant side of the condition. If the indexed column is usually accessed through a function (e.g NVL), consider creating a function based index.
14. Try to use an index if less than 5% of the data needs to be accessed from a data set. The exception is a small table (a few hundred rows) which is usually best accessed through a FULL table scan irrespective of the percentage of data required.
15. Use equi-joins whenever possible, they improve SQL efficiency
16. Avoid the following kinds of complex expressions:
    • NVL (col1,-999) = ….
    • TO_DATE(), TO_NUMBER(), and so on
These expressions prevent the optimizer from assigning valid cardinality or selectivity estimates and can in turn affect the overall plan and the join method
17. It is always better to write separate SQL statements for different tasks, but if you must use one SQL statement, then you can make a very complex statement slightly less complex by using the UNION ALL operator
18. Joins to complex views are not recommended, particularly joins from one complex view to another. Often this results in the entire view being instantiated, and then the query is run against the view data
19. Querying from a view requires all tables from the view to be accessed for the data to be returned. If that is not required, then do not use the view. Instead, use the base table(s), or if necessary, define a new view.
20. While querying on a partitioned table try to use the partition key in the “WHERE” clause if possible. This will ensure partition pruning.
21. Consider using the PARALLEL hint (only when additional resources can be allocated) while accessing large data sets.
22. Avoid doing an ORDER BY on a large data set especially if the response time is important.
23. Consider changing the OPTIMIZER MODE to FIRST_ROWS(n) if the response time is important. The default is ALL_ROWS which gives better throughput.
24. Use CASE statements instead of DECODE (especially where nested DECODEs are involved) because they increase the readability of the query immensely.
25. Do not use HINTS unless the performance gains clear.
26. Check if the statistics for the objects used in the query are up to date. If not, use the DBMS_STATS package to collect the same.
27. It is always good to understand the data both functionally and it’s diversity and volume in order to tune the query. Selectivity (predicate) and Cardinality (skew) factors have a big impact on query plan. Use of Statistics and Histograms can drive the query towards a better plan.
28. Read explain plan and try to make largest restriction (filter) as the driving site for the query, followed by the next largest, this will minimize the time spent on I/O and execution in subsequent phases of the plan.
29. If Query requires quick response rather than good throughput is the objective, try to avoid sorts (group by, order by, etc.). For good throughput, optimizer mode should be set to ALL ROWS.
30. Queries tend to perform worse as they age due to volume increase, structural changes in the database and application, upgrades etc. Use Automatic Workload Repository (AWR) and Automatic Database Diagnostic Monitor (ADDM) to better understand change in execution plan and throughput of top queries over a period of time.
31. SQL Tuning Advisor and SQL Access Advisor can be used for system advice on tuning specific SQL and their join and access paths, however, advice generated by these tools may not be always applicable (point 28).
32. SQL Access paths for joins are an component determining query execution time. Hash Joins are preferable when 2 large tables need to be joined. Nested loops make work better when a large table is joined with a small table.
Disclaimer: Points listed above are only pointers and may not work under every circumstance. This check list can be used as a reference while fixing performance problems in the Oracle Database.
Suggested further readings
  1. Materialized Views
  2. Advanced Replication
  3. Change Data Capture (Asynchronous)
  4. Automatic Workload Repository (AWR) and Automatic Database Diagnostic Monitor (ADDM).
  5. Partitioning strategies.
Now it’s turn if have any more tips which you have used then do add them in comment section… Your feedback is very valuable and it would be useful for other viewers too.

APPS FORM CREATION USING (TEMPLATE.fmb)

APPS FORM CREATION USING (TEMPLATE.fmb)


   ******* APPS FORM CREATION USING (TEMPLATE.fmb) ********

--> Befor going to create form we need to understand some differences in between Narmal D2K Form & Apps Form
      t.e
          --> Narmal D2k Forms, we can directly Create but we can't Register in Application.
          --> But in Apps Form We can register in Oracle Apps by using the Bellow steps.( Using TEMPLATE.fmb)

-->1. First we need to create Custom (our own) Directory of Oracle Apps Forms.

      Ex: D:\FORM_10g_PLL

-->2. And then we need to Copy some files like (.FMB,.PLL) File and Paste in Custom (Our Own) Direcory of D:\FORM_10g_PLL
  
      These files are : AU--Top,  forms, Resources Folders

      Ex: D:\oracle\VIS\apps\apps_st\appl\au\12.0.0\forms\US

      Note: Here we need to copy the files are    (TEMPLATE.fmb , APPSTAND.fmb)

---> And paste into the Custom (Our Own) directory of D:\FORM_10g_PLL

-->3. And then we need to Copy the file are pll (resource-All Folder)

      Ex: D:\oracle\VIS\apps\apps_st\appl\au\12.0.0\resource

      Note: Hear We need to copy the All Files to the Custom (Our Own) Directory of D:\FORM_10g_PLL

-->4.And the we need to set the Path of Custom (Our Own) Directory ,
      Note: Hear we need Add our custom directory to the Existing  directory.
       
        Ex Nov:- Got the RUN--> need to type as (regedit) and then click on ok

                                       --> Hear we need to Seclect HKEY_LOCAL_MEACHINE
                                       --> And then Select to open SOFTWARE
                           --> And then Select to open ORACLE
                                       --> And then Select to open HOME /HOME0, HOME1
                                       --> And then find to Openn the file name as FORM90_PATH ( D2k 10g version)
                                        FORM60_PATH ( D2k 6i version)
-->5.And then we need to Add our Custom Directory to the existing Directories

     EX: D:\develope\cgenf61\admin;D:\develope\forms90;D:\FORM_10g_PLL

--> So our path is Created

--> And we need Creat a form by using TEMPLATE.fmb ( in our Custo Directory of D:\FORM_10g_PLL)

APPS FORM CREATION USING WIZARD METHOD:
=============================

--> Open the Form Builder

 --> Hear we need creat form by selecting the Form Using Tempalte

       Ex: Nav:--> File-->New-->Form Using Tempalte

     Note: Hear we need to Brows to open  TEMPLATE.fmb ( in our Custo Directory of D:\FORM_10g_PLL)

Note: These Error means

         i am not currect file to copy the custom directory
        
         APSTAND.fmb( This is not our file)
         APPSTAND.fmb( This is our file)
   
    --> so i need to Replace this file then we can avoid the Error
                           
---> Now we Can Open the file TEMPLATE.fmb

Note: Now we Need To Delete the BLOCKS( Existing) in that Form

---> And Then We Need to Create (Data Block, Canvas, Window)

WINDOW CREATION:
=============

--> Create a new window by selectin Create button(+)
--> And Open property pallet(F4) for seting the properties

     Ex: General:
                      Name: APPS_WIZ_W
CANVAS CREATION:
=============
--> Create a new Canvas by selectin Create button(+)
--> And Open property pallet(F4) for seting the properties

Ex: General:
                      Name: APPS_WIZ_C

Note:  Attach WINDOWS to CANVAS & CANVAS to WINDOWS
=====================================

--> Go to The Property Palette(F4)  of CANVAS (APPS_WIZ_C)
    
       Physical:
                   Window: APPS_WIZ_W


--> Go to The Property Palette(F4)  of WINDOW (APPS_WIZ_W)
    
       Functional:
                   Primary Canvas: APPS_WIZ_C


DATA BLOCK CREATION:
===============
--> Create a new Data Block by selectin Create button(+)
--> Then Select tha Use The Data Block Wizard and Click on Ok Button
--> (Display the page next time) Click on Next-->(Table or View) Click on Next--> Type the Table         Name(Ex: PO_HEADERS_ALL) and Click on Refresh Button and Connect to The Data Bace (User Name: apps,         Password: apps, Database: vis)

--> Then Move The Available Columns to Database items And Click on Next-->Next-->(Hear we can edit the Data        Block Name) Click on Next-->Finish--> Click on Next-->
    (LAYOUT MODEL CREATION)--> Hear we can Select our Created CANVAS ( No need to        select , Defoult it will     Shows-->Next--> Hear we need to Move The Available items to Displayed        items-->Next-->Next-->Hear we     can select Form/Tabular (Form) -->Next--Hear we can give the Form Title-->Next-->Finish

--> Then we need to Save(.fmb) & Compile(Ctrl+T) the Form

       Ex: APPS_PO_WIZ_FORM.fmb

--> Note: When ever Compile the Form the (.fmx) will be Created automatically

--> Form is Created     

         

******* FORM REGISTRATION PROCESS ************


--> After Creation of the Form by using (TEMPLATE.fmb)

--> Then we need to Move (.fmb) File in " au-Top or po-Top "

       Ex: au-Top: D:\oracle\VIS\apps\apps_st\appl\au\12.0.0\forms\US

--> Then we need to Move (.fmx) File in " po-Top" (Perticular Resp) Only

       Ex: po-Top: D:\oracle\VIS\apps\apps_st\appl\po\12.0.0\forms\US


--> Login to Oracle Applications

                      operations
                      welcome

--> Form Registering:
      ===========
--> Nav: Application Developer (Responsibilty)--> Application-->Form

--> Hear we need to give

      Ex:   Form                                                    Application    User Form Name                                     
             ======                                              =======    ===========
             APPS_PO_WIZ_FORM ( File name(.fmb))      Purchasing    Apps Po Wiz Form  ( Display the Front End Apps)

--> Save it and Close Form

--> Function Registering:
      =============
--> Nav: Application Developer (Responsibilty)--> Application-->Function

      Ex: Function                        User Function Name  
           ======                       =============   
           APPS_PO_WIZ_FORM ( File name(.fmb))  APPS_PO_WIZ_FORM_FUNC (our wish)
       
           --> Go to the [Properties]  Tab in that same Function

           --> Hear we need to select Type asForm

                      Ex: Type: Form

           --> Go to the [Form] Tab in that same Function

           --> Hear we need to Brow & select our Form Name ( Display the Front End Apps)
  
                      Ex: Form: Apps Po Wiz Form (    User Form Name )

--> Save it and Close the Form Function

Attach "Function to Menu":
=================

--> Go to Nav: Application Developer (Responsibilty)--> Application--> Menu

Note: Hear we need to Get The ' Menu Name  ' of the PO( Perticular ) Responsibility from the Responsibility Window

       Nav: Switch to System Administrator (Responsibilty) -->Security-->Responsibility-->Define

             Hear to give our PO( Perticular ) Responsibility Name using F11 and Ctrl F11  or Find it

              Ex: Responsibility Name: Purchasing, Vision Communications (USA)

              --> And then we can get the Menu Name
 
              Ex: Menu: Purchasing SuperUser GUI

--> After geting the Menu name close the Responsibility Window & Swtch to the Application Developer(Responsibilty)
      --> Go to Nav: Application Developer (Responsibilty)--> Application--> Menu

      --> And enter to find the Menu name, using F11 and Ctrl F11  or Find it

                     Ex: Menu: Purchasing SuperUser GUI

      --> And the To add the (seq no , Prompt, Function Name) to end of the Existing Menus
         
            Ex: seq:702  Prompt: APPS_WIZ_PO_FORM Function: APPS_PO_WIZ_FORM_FUNC ( Brows our User Function                  Name)

--> Save it & Close the Menus form

--> And Switc to the Purchasing, Vision Communications (USA) Responsibilities

--> Go to End of the Navigator of PO Resp  And Click on to open the out put of our Form

***--> So the Error will come Becouse of we need set some properties in the Form Builder and Over Come This           Problem

Note: To set The 4 Tasks in Form Builder

         t.i.  1. Subclass information
               2. Change tha Properties of Form
               3. PRE-FORM
               4. APPS Custom Package Body
Note: 4the step is Common in every ware in form we need to provide.

1.Subclass information
===============
Note: 1.This Subclass information we need to set in (Data Block, Items , Convas, Window)
         2. When ever to set the Subclass information that file is Changed to Red color


--> Go to Set the bellow navigation And set Subclass information

Data Block Level:
---------------
-->  Go to Select-->Data Block-->Property palette of (F4) (PO_HEADERS_ALL)

        -->select the (*)Property Class
        -->Property Class Name: BLOCK
        -->Module: APPS_PO_WIZ_FORM ( Form Name)

--> Click on Ok

Items Level:
----------
--> Go to select--> Items( Like Item1)-->Property palette of (F4) of Item1

           Ex: PO_HEADER_ID

        -->select the (*)Property Class
        -->Property Class Name: Text_Item
        -->Module: APPS_PO_WIZ_FORM ( Form Name)

Note: Set the properties of All The Available Items like Above Ex.

Canvas Level:
------------
--> Go to select-->Canvas-->Property palette of (F4)(APPS_WIZ_C)

        -->select the (*)Property Class
        -->Property Class Name: Canvas
        -->Module: APPS_PO_WIZ_FORM ( Form Name)

Widow Level:
-----------
--> Go to select-->Windows-->Property palette of (F4)(APPS_WIZ_W)


        -->select the (*)Property Class
        -->Property Class Name: Window
        -->Module: APPS_PO_WIZ_FORM ( Form Name)

2. Change tha Properties of Form:
======================

--> Go to the Property Palette(F4)  of Form Leve

      Ex: FORM-->APPS_PO_WIZ_FORM(Form Name)

          Navigation:
        First Navigation Data Block: PO_HEADERS_ALL (Data Block Name)

3. PRE-FORM:
=========

--> Go to the PRE-FORM of Form Level Trigger

      NaV: Trigger( Under the Form)-->PRE-FORM--F11(To open the Pl/sql Editor) and set the bellow

Note:
===    FND_STANDARD.FORM_INFO('$Revision: 120.0                                                                                                                                              $', 'Template Form', 'FND',
                       '$Date: 2005/05/06 23:25  $', '$Author: appldev $');
          app_standard.event('PRE-FORM');
          app_window.set_window_position('BLOCKNAME', 'FIRST_WINDOW');----> Need To Change This Line Only

---> above code is Defoult , just we need to Replace the ('BLOCKNAME'(Data Block name)  , 'FIRST_WINDOW' Window         name )

---> 'FIRST_WINDOW'  Window name is Optional No Need to Replace

---> Need to Replace the BLOCKNAME to PO_HEADERS_ALL(Data Block name)

   Ex: app_window.set_window_position('BLOCKNAME', 'FIRST_WINDOW'); (Default)

        app_window.set_window_position('PO_HEADERS_ALL', 'FIRST_WINDOW');---Yes


--> Compile it ( Ctrl+T)

4. APPS Custom Package Body:
===================

-->Go to Select the " Program Units" in Form Builder
--> And then to  Select the APP_CUSTOM (Package Body)-->Go to the Pl/Sql Editor
--> Hear we need to set the Window name in if Condition

--> The bellow Code is Defoult in APP_CUSTOM (Package Body)

--> In bellow condition we need to replace as( your first window to APPS_WIZ_W(Window name) )

         if (wnd = '<your first window>') then ----> Need To Chang This Line Only
    app_window.close_first_window;
  elsif (wnd = '<another window>') then
    --defer relations
    --close related windows  
    null; 
  elsif (wnd = '<yet another window>') then
    --defer relations
    --close related windows  
    null;
  end if;

--> Then we need to Save & Compile (Ctrl+T) it

--> Then Login To the Oracle Application -->

--> And Switch to the Purchasing, Vision Communications (USA) Responsibilities

--> Go to End of the Navigator of PO Resp  And Click on to open the out put of our Form

Note: Form is Successfully Registered Here  we Can manupulate the DML Opertaions.

problem installing oracle developer Suite 10g on window 7 64 bit




Since last few days I was struggling to connect with Forms/Report 10g installed on my system, today I got the solution for this, so thought of to share with everyone, so that it might help everyone in future if anyone is installing developer 10g.


Issue  was :

My setup directory (Folder) was having space.
Like earlier my setup file was in

C:\A Stryker Work\Softwares\Oracle\Oracle Developer Suite 10g Working\ds_windows_x86_101202_disk1

So here “Oracle Developer Suite 10g Working”, this folder was containing few spaces.

Solutions:

I copied setup folder directly in C:/ Directory , and without spaces, then installed again, now I am able to connect successfully.


“C:\Oracle_dev_suite\ds_windows_x86_101202_disk1”

Query to get Set of Books, Operating Unit, Organization data

SELECT gl.set_of_books_id,
gl.name,
gl.short_name,
hou.name operatin_unit,
hou.organization_id operating_unit_id,
org.organization_name warehouse_name,
org.organization_id warehouse_id
 FROM org_organization_definitions org,
 hr_operating_units hou,
 gl_sets_of_books gl
 where org.operating_unit=hou.organization_id
 and hou.set_of_books_id = gl.set_of_books_id
order by 1,3,6

Wednesday, August 17, 2016

FND Profile and FND Global Values

FND_PROFILE and FND_GLOBAL values



Following are the FND_PROFILE values that can be used in the PL/SQL code:

   fnd_profile.value('PROFILEOPTION');
   fnd_profile.value('MFG_ORGANIZATION_ID');
   fnd_profile.value('ORG_ID');
   fnd_profile.value('LOGIN_ID');
   fnd_profile.value('USER_ID');
   fnd_profile.value('USERNAME');
   fnd_profile.value('CONCURRENT_REQUEST_ID');
   fnd_profile.value('GL_SET_OF_BKS_ID');
   fnd_profile.value('SO_ORGANIZATION_ID');
   fnd_profile.value('APPL_SHRT_NAME');
   fnd_profile.value('RESP_NAME');
   fnd_profile.value('RESP_ID');

Following are the FND_GLOBAL values that can be used in the PL/SQL code:

   FND_GLOBAL.USER_ID;
   FND_GLOBAL.APPS_INTIALIZE;
   FND_GLOBAL.LOGIN_ID;
   FND_GLOBAL.CONC_LOGIN_ID;
   FND_GLOBAL.PROG_APPL_ID;
   FND_GLOBAL.CONC_PROGRAM_ID;
   FND_GLOBAL.CONC_REQUEST_ID;

For example, I almost always use the following global variable assignments in my package specification to use throughout the entire package body:

   g_user_id      PLS_INTEGER  :=  fnd_global.user_id;
   g_login_id     PLS_INTEGER  :=  fnd_global.login_id;
   g_conc_req_id  PLS_INTEGER  :=  fnd_global.conc_request_id;
   g_org_id       PLS_INTEGER  :=  fnd_profile.value('ORG_ID');
   g_sob_id       PLS_INTEGER  :=  fnd_profile.value('GL_SET_OF_BKS_ID');

And initialize the application environment as follows:

   v_resp_appl_id  := fnd_global.resp_appl_id;
   v_resp_id       := fnd_global.resp_id;
   v_user_id       := fnd_global.user_id;
     
   FND_GLOBAL.APPS_INITIALIZE(v_user_id,v_resp_id, v_resp_appl_id);

Clear BNE Cache for WebADI Changes

It Sometime happens that WebAdi Changes doesn't reflect once migrated in controlled instances. Here are the quick steps(Generally perfor...