Friday, 5 June 2015

How to avoid duplicate records block level or record level in oracle forms?

Form program unit:
================================

Function COMPARAISON (val1 varchar2, val2 varchar2)
Return number
Is
   answer number := 0;
Begin
   if val1 = val2 then
      answer := 1;
   end if;
   return(answer);
End;


3 new hidden fields need to add: two fields need to add control block another one data block

CONTROL.PK_COPY--------------number(data type)

DATABLOCK.MATCH_FOUND--------number(data type)
calculation mode: formula
formula: COMPARAISON(:control.PK_COPY, :XXPO_SOR_REQUISITION_DETAILS.ITEM_ID || :XXPO_SOR_REQUISITION_DETAILS.ITEM_CODE) --you are block name.item name
either sing item or multiple items


CONTROL.MATCH_FOUND--------number(data type)

calculation_mode: summary
summary_function: Sum
summarised_block: DATABLOCK
summarised_item: MATCH_FOUND

WHEN_VALIDATE_RECORD
:control.PK_COPY := :XXPO_SOR_REQUISITION_DETAILS.ITEM_ID || :XXPO_SOR_REQUISITION_DETAILS.ITEM_CODE
If : control.match_found > 1 then
fnd_message.set_string('Item Code Already Exist');
fnd_message.show();
raise form_trigger_failure;
end if;

(OR)

WHEN_VALIDATE_ITEM on data block primary key column
:control.pk_copy := :XXPO_SOR_REQUISITION_DETAILS.ITEM_ID || :XXPO_SOR_REQUISITION_DETAILS.ITEM_CODE;
if :control.MATCH_FOUND > 1 then
fnd_message.set_string('Item Code Already Exist');
fnd_message.show();
raise form_trigger_failure;
end if ;


The Data block must have the following properties setting:(Block level)

Query all records = YES


The CONTROL block must have the following properties setting:(Block Level)

Query all records =YES
Single record =YES
Database data block =NO


(DATABLOCK must have query_all_records = TRUE)

============================================================

No comments:

Post a Comment