Tuesday, April 30, 2013

Differences between 11i and R12


Sunday, April 28, 2013

Workflow tables and its usage




WF_ITEM_TYPES:
The wf_item_types table contains one record for each item_type created. The eight character name of the item_type represents the “Internal Name” of the item. It also functions as the primary key for this table. Some key columns are:
§  NAME: It is a mandatory field. It represents the internal name of the item type.
§  PROTECT_LEVEL: Level at which the data is protected. A mandatory field.
§  CUSTOM_LEVEL: Level of user who last updated the row. Again a mandatory field.
§  WF_SELECTOR: It stores the name of the PL/SQL procedure which implements selector function. This is an optional field.
§  PERSISTENCE_TYPE: Indicates whether item type is temporary or permanent.
§  PERSISTENCE_DAYS: Number of days until purge if persistence is temporary.
Workflow Item Type Display Name and description can be found in WF_ITEM_TYPES _TL table. 

WF_ITEM_ATTRIBUTES:
This table stores definitions of attributes associated with a process. The entries in this table correspond to the “Attributes” subheading in the Workflow Builder. An item attribute works like a variable which can hold values that are specific to the process instance or which may change at run time. Some key columns are:
§  ITEM_TYPE: Internal name for the item type that owns the attribute. A mandatory field.
§  NAME: Internal name of the attribute. A mandatory field.
§  SEQUENCE: Order of the attribute within the message
§  TYPE: Each item attribute is assigned a datatype, such as “Character”, “Number”, or “Date”.
There are three fields to hold a default value, but only one of them will be populated for any item attribute, depending upon the datatype. For example, if you create an item attribute with a datatype of “Number”, and then supply a default value, that value would be stored in the “number_default” field.
The “format” field stores information about a format mask that should be applied to number or date values, and the “subtype” field contains “SEND” or “RECEIVE”. The Translation table is WF_ITEM_ATTRIBUTES_TL and the related view is WF_ITEM_ATTRIBUTES_VL.

WF_ACTIVITIES:
This table stores the definition of an activity. Activities can be processes, notifications, functions or folders. A process activity is a modeled workflow process, which can be included as an activity in other processes to represent a sub-process. A notification activity sends a message to a performer. A functions activity performs an automated function that is written as a PL/SQL stored procedure. A folder activity is not part of a process, but it provides a means of grouping activities. Some key columns are:
§  ITEM_TYPE: Internal name for the Item Type that owns the message.
§  NAME: Internal name for the activity.
§  VERSION: It is used to support multiple versions of the same process running at the same time. The version number works in concert with the “begin_date” and “end_date” fields, to ensure that only one version of any activity is active at any given time. By versioning, the previously launched processes retain the process definition that was in force at the time they were launched.
§  TYPE: The “type” field is the way that the individual types of activities can be distinguished. There are five valid values found in the “type” field: “FUNCTION”, “NOTICE”, “EVENT”, “PROCESS”, and “FOLDER”.
§  RERUN: Determines if activity is rerun during looping.
§  EXPAND_ROLE: Determines how many roles are required to respond to a notification activity.
§  FUNCTION: For function activities only, the field is used to store the name of the PLSQL procedure that the Workflow Engine should call to implement the function.
§  RESULT_TYPE: If you intend to model transitions in a process based upon values returned by an activity node, then the expected results must be predefined by supplying a lookup type, which is stored in this field.
§  ICON_NAME: Name of activity icon used in process window.
§  MESSAGE: For notification activities only, the field called “message” will be populated. In these cases, it will contain the internal name of the message that the notification will deliver.
§  ERROR_PROCESS: Workflow process to run in case of an error.
§  ERROR_ITEM_TYPE: Name of item type to execute in case of error.
§  RUNNABLE_FLAG: Flag (Y or N) to indicate if activity is runnable.
§  FUNCTION_TYPE: Indicates whether function type is pl/sql or internal.

WF_ACTIVITY_ATTRIBUTES:
This table defines attributes which behave as parameters for an activity. Activity attributes are only used by function activities. Each row includes the associated activity, type of attribute, and the format used by the activity. Examples of valid attribute types are DATE, DOCUMENT, FORM, ITEMATTR, LOOKUP, and VARCHAR2. Notice that the table requires three fields just to identify to which activity the attribute is attached: the item_type, name, and version of the activity. To join this table to the wf_activities tables you must join all three of these fields to their corresponding fields in that table. Some key columns are:
§  ACTIVITY_ITEM_TYPE: Item type the activity is associated with
§  ACTIVITY_NAME: Internal name of the activity
§  ACTIVITY_VERSION: Version of the activity
§  NAME: Internal name of the attribute
§  SEQUENCE: Order of the attribute within the message
§  TYPE: This field refers to the datatype of the values that the attribute will contain.
§  VALUE_TYPE: Defines if the default is a constant or a reference to an item attribute.

WF_ACTIVITY_ATTR_VALUES:
This table used to track values contained in activity attributes. This table is identical in purpose to wf_item_attribute_values except it holds values for activity attributes instead of item attributes. Each row includes the process activity id and the associated value for the attribute. The interesting thing about this table is that it uses the process_activity_id to identify the activity to which the attribute is attached. The same activity can be inserted into a process more than one time, so the only way to uniquely identify the node to which this attribute is attached is to use the process_activity_id.

WF_MESSAGES:
The messages that are associated with notifications are stored in this table. Each message, which is uniquely identified by the combination of item_type and message_name (stored in the fields “type” and “name”) receives a single record in the wf_messages table. The actual text of the message is stored only in its localization table (wf_messages_tl). They can found in the “body” and “html_body” fields.

WF_MESSAGE_ATTRIBUTES:
This table contains message attribute definitions. Each message may have zero or more message attributes. Message attributes define additional information that is to be sent to, or received from the user. These attributes can be used as tokens in the subject or body of a message template to place variables values into the message at runtime.

WF_PROCESS_ACTIVITIES:
A process is a sequence of activities performed in a pre-determined order. When you create a process definition in the Workflow Builder by dragging various notifications and functions into the process window, the records created by the Builder are stored into this table.

WF_ACTIVITY_TRANSITIONS:
The flow of a process from node to node as indicated by the transition arrows is not saved in the wf_process_activities table. Instead this information is stored in this table.
A transition is defined by three discrete pieces of information: the node where the arrow begins, the node toward which the arrow points, and the result which, when returned by the beginning node, causes the transition to be followed. Not surprisingly, it is those three fields which are the most important fields in this table: “from_process_activity”, “to_process_activity”, and “result_code”. The values stored in “from_process_activity” and “to_process_activity” are numbers which represent the instance_id of the records from wf_process_activities from which and to which the transition is moving.

WF_LOOKUP_TYPES_TL & WF_LOOKUPS_TL:
Wf_lookup_types_tl is the table used to set up the types of results expected from Workflow activities like functions and notifications. This table does not contain the actual result values, it holds the groupings of the result_codes – the names you see in the Workflow Builder as the names of the Lookups. Wf_lookups_tl is the table that stores the component values that comprise a lookup_type.

Saturday, April 27, 2013

Overview of workflow background engine and it is statuses


The Workflow Engine manages all automated aspects of a workflow process for each item. The engine is implemented in server-side PL/SQL and is activated whenever a call to a workflow procedure or function is made. Since the engine is embedded inside the Oracle Database, if the Workflow server goes down for any reason, the Oracle Database is able to manage the recovery and transactional integrity of any workflow transactions that were running at the time of the failure.

Additionally, Workflow engines can be set up as background tasks to perform activities that are too costly to execute in real time.
The Workflow Engine performs the following services for a client application:
  • It manages the state of all activities for an item, and in particular, determines which new activity to transition to whenever a prerequisite activity completes.
  • It automatically executes function activities (execution is either immediate or deferred to a background engine) and sends notifications.
  • It maintains a history of an activity's status.
  • It detects error conditions and executes error processes.
Based on the result of a previous activity, the engine attempts to execute the next activity directly. An activity may have the following status:
  • Active - activity is running.
  • Complete - activity completed normally.
  • Waiting - activity is waiting to run.
  • Notified - notification activity is delivered and open.
  • Deferred - activity is deferred.
  • Error - activity completed with error.
  • Suspended - activity is suspended.

Important: The Workflow Engine traps errors produced by function activities by setting a savepoint before each function activity. If an activity produces an unhandled exception, the engine performs a rollback to the savepoint, and sets the activity to the ERROR status. For this reason, you should never commit within the PL/SQL procedure of a function activity. The Workflow Engine never issues a commit as it is the responsibility of the calling application to commit.
For environments such as database triggers or distributed transactions that do not allow savepoints , the Workflow Engine automatically traps "Savepoint not allowed" errors and defers the execution of the activity to the background engine.
Oracle Workflow components that continue workflow processing asynchronously, such as background engines and the Notification System, do issue commits when appropriate on behalf of the calling application.

how to check the workflow status from back end in oracle applications


SELECT wat1.display_name "process name", wat.display_name "activity name",
       wa.FUNCTION "function",wa.*
  FROM wf_process_activities wpa,
       wf_activities_tl wat,
       wf_activities_tl wat1,
       wf_activities wa,
       wf_item_activity_statuses wias_h
WHERE wpa.activity_item_type = wa.item_type
   AND wpa.instance_label = wa.NAME
   AND wat.item_type = wa.item_type
   AND wat.version = wa.version
   AND wat.LANGUAGE = 'US'
   AND wat.NAME = wa.NAME
   AND wat1.NAME = wpa.process_name
   AND wat1.item_type = wat.item_type
   AND wat1.version = wat.version
   AND wat1.LANGUAGE = wat.LANGUAGE
   AND wat1.version = wpa.process_version
   AND wias_h.item_type = 'OEOL'
   AND wias_h.process_activity = wpa.instance_id
   AND wias_h.item_key = :item_key

Tuesday, April 23, 2013

how to kill the session in oracle 11g


The alter system kill session command requires two unique arguments that uniquely identify the Oracle session, the session identifier and serial number.
First you have to identify the session to be killed with alter system kill session.

select SID,SERIAL# from v$session where sid = 666

SID   SERIAL#
-------------------
666 34409

The SID and SERIAL# values of the Oracle session to be killed can then be substituted and the alter system kill session command issued.

alter system kill session '130,620,@1';
                                                                     SID , SERIAL#,inst_id

inst_id can get it from gv$session for the session id which you want to kill.

Friday, April 12, 2013

How to Migrate DFF from one instance to another instance


Run the below download command in home directory of Instance1, the ldt file descript_flex.ldt is created in the same directory.

FNDLOAD apps/<password> 0 Y DOWNLOAD @FND:patch/115/import/afffload.lct descript_flex.ldt desc_flex_application DESCRIPTIVE_FLEXFIELD_NAME=description_flexfield_name

desc_flex_application - is the shortname of the Application of the DFF.
description_flexfield_name - This is not title of the DFF.

To get description_flexfield_name:
Open the DFF in Application DeveloperàFlexfieldàDescriptiveàSegments

click help->diagnostics->examine->
block=table, field=DESCRIPTIVE_FLEXFIELD_NAME.
The value in the field “Value” is the description_flexfield_name.

For Example, The description_flexfield_name of the DFF “Additional Information” in the above screenshot is: CS_INCIDENTS_ALL_B_EXT.
Application is: Service.
Short name of Service is: CS
And the download command is:

FNDLOAD apps/<password> 0 Y DOWNLOAD @FND:patch/115/import/afffload.lct descript_flex.ldt CS DESCRIPTIVE_FLEXFIELD_NAME=CS_INCIDENTS_ALL_B_EXT



/*Upload description flexfield*/
Transfer the ldt file descript_flex.ldt from Instance1 to the home directory of the Instance2 and run the below upload command in the same directory.

FNDLOAD apps/apps 0 Y UPLOAD @FND:patch/115/import/afffload.lct descript_flex.ldt


/*Compiling description flexfield*/
After migration, run the below compilation command to compile the flexfield in the Instance2.

fdfcmp apps/<password> 0 Y D desc_flex_application description_flexfield_name

Tuesday, April 9, 2013

Read only tables in Oracle 11g

Oracle 11g database categorizes tables based on their transactional behavior; they can be READ ONLY or READ WRITE. A READ ONLY table remains passive against all DML operations, selective DDL operations, and flashback activities. The permissible actions on a READ ONLY table includes selection, indexing, enforce constraints, rename, and dropping.

With the addition of this category, Oracle added another obvious category as READ WRITE. A table, which is open for all transactional activities, falls under this category. The category can be toggled over at any point of time in the session using ALTER TABLE command.

A table would be created in conventional manner but it can be altered to READ ONLY mode.

Example

ALTER TABLE [TABLE NAME] [READ ONLY | READ WRITE]

Example

SQL> ALTER TABLE EMPLOYEES READ ONLY;
Table altered.

The below ALTER TABLE statement switches back the table mode to READ WRITE.


SQL> ALTER TABLE EMPLOYEES READ WRITE;
Table altered.
READ ONLY tables are extremely useful in tightening the security at user level. Earlier, the same objective was achieved by a statement level DML trigger or a check constraint in ‘disable validate’ state. But READ ONLY table provides a simple and reliable technique to impose DML restriction on a table.

Thursday, April 4, 2013

How do I calculate the table space size in oracle


SELECT   /* + RULE */
         df.tablespace_name "Tablespace",
         df.bytes / (1024 * 1024 * 1024) "Size(GB)",
         SUM (fs.bytes) / (1024 * 1024 * 1024) "Free(GB)",
         NVL (
            ROUND (
               SUM (fs.bytes) * 100 / df.bytes
            ),
            1
         ) "%Free",
         ROUND (
            (  df.bytes
             - SUM (fs.bytes)
            ) * 100 / df.bytes
         ) "%Used"
    FROM dba_free_space fs,
         (SELECT   tablespace_name, SUM (bytes) bytes
              FROM dba_data_files
             WHERE tablespace_name LIKE 'ONTD%'
          GROUP BY tablespace_name) df
   WHERE fs.tablespace_name(+) = df.tablespace_name
GROUP BY df.tablespace_name, df.bytes
ORDER BY 3 DESC