Apply Search Domain to Entity

When creating a Search Domain you need to make the following changes to the Entity:

  1. Add a search domain to the entity model.
  2. Add the Index Column (TEXT_ID$) to the table.
  3. Create a unique index on the Index Column (TEXT_ID$).
  4. Add the Index Column (TEXT_ID$) to the main view used by the search domain.

Some code samples for the above actions

ALTER TABLE Fnd_User_Tab ADD Text_ID$ VARCHAR2(100) DEFAULT SYS_GUID() NOT NULL;

DECLARE
   columns_    Installation_SYS.ColumnTabType;
   table_name_ VARCHAR2(30) := 'FND_USER_TAB';
BEGIN
   Installation_SYS.Reset_Column_Table(columns_);
   Installation_SYS.Set_Table_Column(columns_, 'TEXT_ID$', 'VARCHAR2(100)', 'Y', 'SYS_GUID()');
   Installation_SYS.Alter_Table(table_name_, columns_, TRUE); 
   Installation_SYS.Reset_Column_Table(columns_);
   Installation_SYS.Set_Table_Column(columns_, 'TEXT_ID$', 'VARCHAR2(100)', 'N');
   Installation_SYS.Alter_Table(table_name_, columns_, TRUE); 
END;

DECLARE 
   columns_ Installation_SYS.ColumnTabType; 
BEGIN 
   Installation_SYS.Set_Table_Column(columns_, 'TEXT_ID$'); 
   Installation_SYS.Create_Index('FND_USER_TAB', 'FND_USER_IX3', columns_,
                                 'U', '&fnd_index', '&normal', TRUE, TRUE); 
END; 
/

CREATE OR REPLACE VIEW Fnd_User AS
SELECT identity identity,
       description description,
       oracle_user oracle_user,
       web_user web_user,
       active active,
       rowid objid,
       ltrim(lpad(to_char(rowversion),2000)) objversion,
       text_id$ text_id$
FROM fnd_log_tab
WITH read only
/

Special considerations

Multiple search domains for an entity

It is possible to define more than one search domain for an entity. When doing so you have to make sure you use unique names for Name, Index Name, Index Column Name and Package Name. Also note the views listed in Enabled In can only be used in a single search domain.

Logical Units with inheritance

If your logical unit is based on inheritance where two or more LU's share a common database table you typically have one entity for each such LU. If you create search domains for such entities the same rules as for multiple search domains for an entity applies - you have to make sure you use unique names, especially for the Index Column Name column since there may be more than one such column in the shared database table. You should also check the Handle Invalid Rows checkbox on the search domain details tab in order to ignore errors reported during indexing. (Not all table rows will be visible in the database view.)

Search domains with LOB attributes

Since it is not possible to catch changes in LOB attributes when a trigger is fired (no support for LOB's in triggers) you must fix the un-synchronization by yourself in the business logic. The way to do this depends on if the LU is used directly by a Windows Client (Centura) and/or if it is exposed an entity in Extended Server.

Windows Client

The Windows Client will always call a method called 'Write-something' to update the LOB column (but this method is not automatically called from an entity). The following is an example of code when the LOB is on the master entity FndUser in the search domain:

PROCEDURE Write_Picture__(
   objversion_ IN OUT VARCHAR2,
   rowid_      IN ROWID, 
   blob_loc_   IN BLOB ) 
IS
   rec         Fnd_User_TAB%ROWTYPE;  
BEGIN
   General_SYS.Init_Method(lu_name_, 'Fnd_User_API', 'Write_Picture__'); 
   rec := Lock_By_Id___(rowid_, objversion_);
   UPDATE fnd_user_tab
   SET picture = blob_loc_,
       rowversion = SYSDATE
   WHERE rowid = rowid_
   RETURNING to_char(rowversion,'YYYYMMDDHH24MISS'), text_id$ 
        INTO objversion_, rec_.text_id$;
   -- Begin added code
   Application_Search_SYS.Unsync_Document('Users', rec_.text_id$);
   -- End added code
END Write_Picture__;

If the LOB attribute is located on an aggregate you must find the value of the indexed column (text_id$). In the generated PL/SQL package for the search domain you can find methods helping you to get the value of the indexed column. The example below is from the aggregate FndUserProperty:

PROCEDURE Write_Picture__(
   objversion_ IN OUT NUMBER,
   rowid_      IN ROWID, 
   blob_loc_   IN BLOB ) 
IS
   rec         Fnd_User_Property_TAB%ROWTYPE;  
BEGIN
   General_SYS.Init_Method(lu_name_, 'Fnd_User_Property_API', 'Write_Picture__'); 
   rec := Lock_By_Id___(rowid_, objversion_);
   UPDATE fnd_user_property_tab
   SET picture = blob_loc_,
       rowversion = rowversion + 1
   WHERE rowid = rowid_
   RETURNING rowversion, identity 
        INTO objversion_, rec_.identity;
   -- Begin added code
   Application_Search_SYS.Unsync_Document('Users', 
                                          Fnd_User_SD.Key_Properties__(rec_.identity));
   -- End added code
END Write_Picture__;

This page is generated from IFS Developer Studio - for latest update, see help pages in the tool itself.