Tuesday, August 23, 2022

Oracle Forms: Avoid duplicated records in a block

Oracle Forms: Avoid duplicated records in a block

 

Rejecting two records with duplicate values is the goal.

Oracle Forms: Avoid duplicated records in a block

Two computed items are utilised, one in the data block and the other in the control block.

Oracle Forms: Avoid duplicated records in a block

The DEPT block now contains the first computed item (:DEPT.MATCH FOUND). It includes the following formula:

Comparaison(:ctrl.charsave, :dept.deptno||:dept.dname)

Notice in this case,that we want to avoid duplicates on both DEPTNO and DNAME values.

Function COMPARAISON (val1 varchar2, val2 varchar2)

Return number

Is

   answer number := 0;

Begin

   if val1 = val2 then

      answer := 1;

   end if;

   return(answer);

End;

 

COMPARAISON is a program unit stored in the Forms module.

If the two numbers are equal, the function compares them and returns 1 (a value greater than 0). Otherwise, it returns 0.

The current record's backup value is contained in the first value (:ctrl.charsave).

The DEPT block must be configured with the following properties:

Query all records

Yes


The CTRL block must have the following properties setting:

Query all records

Yes

Single Record

Yes

Database Data Block

No


The second computed item is appended to the CTRL block as ":CTRL.MATCH FOUND".

It summarize the values contained in all the rows of the DEPT block (dept.match_found).

If the total is greater than 1, we have two duplicated data.


I hope it's helpful for you. If you have any queries, don't hesitate to contact me.

Name : Muhammad Sahal Qasim
E-mail : s.m.sahal789@gmail.com

Thank you.

0 comments:

Post a Comment

If you have any doubts, please let me know. I will help you.