Adpatch is a utility provide for applying patches in the Oracle Apps. Patching is perfomed for updating the files verison, bug fixing or while doing upgrades.

Patch can be applied 2 ways

1.Offline  (taking application services down) . We need to enable maintenance mode before applying patch in offline mode using adadmin utility.
2.Online  (with application services running). We need to use hotpatch option while applying patch in online mode

There are 3 modes in which adpatch runs.

Modes of ADPATCH

1) Pre-Install Mode
Pre-install mode is used to update AD utilities before an upgrade and to apply family consolidated upgrade packs.
AutoPatch Pre-AutoInstall mode allows you to apply patches when your installation is missing database information and/or filesystem information that AutoPatch requires to run in normal mode.
Examples of when you would run AutoPatch in Pre-AutoInstall mode (and cannot run it in normal mode) include:
    Prior to installing Oracle Applications for the first time
    Prior to upgrading Oracle Applications to the latest release.
    During an upgrade (to apply a bug fix that stopped your upgrade)
Applying patch in pre-install mode performs following tasks:
    Version checking
    File copy actions
    Relink FND and AD executables
    Save patch history information to file system
AutoPatch in pre-install mode will NOT:
    Run SQL of EXEC command
    Generate files
    Read product driver files
    Apply maintenance pack
To apply patch in pre-install mode, run  adpatch preinstall=y

2) Test Mode
AutoPatch provides a test mode in which it tells you everything it would have done in applying a patch, but doesn’t actually apply the patch.
To run AutoPatch in Test Mode, you must include ‘apply=no’ on the AutoPatch command line. For example:
$ adpatch apply=no
Instead of performing an action, AutoPatch indicates that it is not performing the action because “Apply=No”. In general, AutoPatch lists each file it would have copied, generated, relinked, or executed. This shows you exactly what actions it would have performed.
AutoPatch test mode works the same as normal mode, with the following exceptions:
    It does not copy any files from your patch directory into your installation area.
    It does not copy any files from your APPL_TOP to JAVA_TOP or OAH_TOP.
    It does not archive any object modules into your product libraries.
    It does not generate any forms or reports.
    It does not relink any executables.
    It does not run any ‘sql’ or ‘exec’ commands.
    It does not update the release version in the database.
    It does not update the patch history file.
AutoPatch asks you the same initial questions in test mode as in normal mode. It performs the following actions to determine what it would have done if run in normal mode:
    Reads and validates the patch driver file.
    Reads product file driver files.
    Extracts object modules from your product libraries (so it can perform version checking on the object modules it extracts).
    Performs version checking.
    Looks in the database to determine what ‘sql’ and ‘exec’ comands it would have run.
Its a good practice to run the patch in test mode and analyze the things before applying the patch in normal mode.

3) Non-Interactive Mode
Starting in Release 11.5, you can run AutoPatch non-interactively bycreating a defaults file

Before you can run AutoPatch non-interactively, you must first create an AutoPatch defaults file for your current environment.

Steps for creating AutoPatch defaults file for your current environment:
1. Specify defaultsfile=<New Defaults File Name> on the AutoPatch command line. The defaults file must be located under $APPL_TOP/admin/<SID>.
For example:
adpatch defaultsfile=$APPL_TOP/admin/testdb1/my_def.txt
2. Run AutoPatch up to the point where it asks you for the directory where your Oracle Applications patch has been unloaded. Then type ‘abort’ at this prompt.
3. Verify that your defaults file exists.
Once you have an AutoPatch defaults file for your current environment, you can run AutoPatch non-interactively.
Applying a single patch driver file non-interactively
Before applying any Oracle Applications patch, either interactively or non-interactively, you should read the README file (usually called readme.txt) supplied with the patch. You should also read the documentation supplied with the patch (if any).
It is possible to apply just a single patch driver file non-interactively using AutoPatch. Here is an example:
Assume the following:
    defaults file is $APPL_TOP/admin/testdb1/def.txt
    Applying copy driver for patch 987654, which is located in directory $APPL_TOP/patch/987654.
    Using three parallel workers
    AutoPatch log file name is cpy987654.log
The AutoPatch command line would be:
adpatch defaultsfile=$APPL_TOP/admin/testdb1/def.txt \
logfile=cpy987654.log \
patchtop=$APPL_TOP/patch/987654 \
driver=u987654.drv \
workers=3 \
If we dont give any of the mode as mentioned above and apply the patch simply using adpatch command then its a normal mode of patch application.

Various Options used during adpatch.

Either these can be passed like <option_name>=<value> or adpatch will ask these value once its start executing.

adpatch option_name= value
ex. adpatch defaultsfile=$APPL_TOP/admin/testdb1/def.txt
adpatch workers=16

1) defaultsfile
Purpose: This option is used when we are running the patch in non interactive mode. In that case we create defaults file and provide that file as an option for running patch in non-interactive mode.
Default: none. No default file read or written.

2) logfile
Purpose: This is the name of adpatch log file which it will write during patch application.
Default: none. Adpatch prompts for this value.

3) workers
Purpose: Specifies the number of workers to run. This value depends on number of CPU and other factors.
Default: none. Adpatch prompts for this value.

4) patchtop
Purpose: Top-level directory for the current patch. This is the directory after unzipping the patch. This directory will a patch number.
Default: none. Adpatch prompts for this value.

5) driver
Purpose: Name of the patch driver file. This comes with the patch and is present in patch directory.
Default - none. Adpatch prompts for this value.

6) restart
Purpose: To restart an existing session. Only valid when interactive=no is also specified
Default: No

7) localworkers
Purpose: Used in Distributed AD to specify the number of workers to be run on the current machine. If you have multi node instance (example RAC and shared APPL_TOP), then you can utilize this paramter to run the patch parallely in multiple nodes. You can start few workers on node 1, few on node 2 and so on. The way this can be done is that, you can start adpatch on one node with localworker=<some value less then total workers>. Then run adctrl on other node in distributed mode and start some mode workers. This will speed up the process and utilized the resources effectively.
Default: Value specified for workers.

8) printdebug
Purpose: To display extra debugging information.
Default: No.

Some other parameters which can be helpful for application of speeding up the patch application.

adpatch options=<value>
1) checkfile
Purpose: To skip running exec, SQL, and exectier commands if they are recorded as already run. Indicates that Autopatch should run the command *only* if a certain file is newer than the version of it that was last run. The idea behind it is to reduce the duration of an Autopatch session by skipping actions that don’t really need to be performed. When used in the right manner, it can dramatically improve Autopatch performance, especially for big patches and/or long running actions.
Default: checkfile (use ‘nocheckfile’ to skip)

2) compiledb
Purpose: To compile invalid objects in the database after running actions in the database driver.
Default: compiledb (use ‘nocompiledb’ to skip)

3) compilejsp
Purpose: To compile out-of-date JSP files, if the patch has copy actions for at least one JSP file.
Default: compilejsp (use’nocompilejsp’ to skip)

4) copyportion
Purpose: To run commands found in a copy driver. This will copy the higher version files from patch to product top.
Default: copyportion (Use ‘nocopyportion’ to skip. Use it only when mentioned in readme of patch)

5) databaseportion
Purpose: To run commands found in a database driver. This portion includes applying the files (like sql, pls etc) to database.
Default: databaseportion (use ‘nodatabaseportion’ to skip. Use it only when mentioned in readme of patch)

6) generateportion
Purpose: To run commands found in a generate driver. This portion will generate new executable files from the copied code of patch. For example if will generate new forms files (fmx) from new .fmb files.
Default: generateportion (use ‘nogenerateporation’ to skip)

7) integrity
Purpose: To perform patch integrity checking. Tells adpatch whether to perform patch integrity checking, which verifies that the version of each file referenced in a copy action matches the version present in the patch.
Default: nointegrity (By default the integrity is not checked)

8) maintainmrc
Purpose: To maintain the MRC schema after running actions found in the database driver.
Default: maintainmrc (use ‘nomaintainmrc’ to skip)

9) autoconfig
Purpose: Tells adpatch to run Autoconfig after patch installation.
Default: autoconfig (use ‘noautoconfig’ to skip)

10) parallel
Purpose: To run actions that update the database or actions (like SQL) that generate files in parallel (like genform).
Default: parallel (use ‘noparallel’ to skip)

11) prereq
Purpose: Tells adpatch whether to perform prerequisite patch checking prior to running patch driver files that contain actions normally found in the copy driver.
Default: prereq (use ‘noprereq’ to skip)

12) validate
Purpose: To connect to all registered Oracle Applications schemas at the start of the patch. Adpatch validates the passwords for each schema.
Default: novalidate (use ‘validate’ to validate schema passwords)

Below Flags can be passed to adpatch

1) hidepw
Purpose: This argument is used to hide the passwords in log files
Default: nohidepw
adpatch flags=nohidepw
2) trace
Purpose: Tells the adpatch utility whether to log all database operations to a trace file
Default: notrace
adpatch flags=notrace
3) logging
Purpose: Tells the adpatch utility whether to create indexes using the logging or nologging mode.
Default: logging
adpatch flags=logging

Log File Location

Patch log file location:

Worker Log file location: