How to do a validation in a multi-record block in when-validate record

Hello Forms61 experts,
        I have a problem that need a solution ASAP.  I have a multi-record block based on a table.
       The 3 items on the block are:  Type,  Description and Serialnumber.


       Example:  The values of the 3 items are:
          Type               Description              Serialnumber
          mm                mm device               123
          mm                mm device2             456

        The second value    "mm           mm device2        456"   is not a valid entry. They cannot enter the same type.
        How do I do the validation? so that when they enter the same type, it will give a message that "You Cannot Enter the Same Type of Device"?

Thanks,
Terry        
TComandanteAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

riazpkCommented:
If you want to do it in WHEN-VALIDATE-ITEM trigger, use:

DECLARE
 TYPE mytype is TABLE of VARCHAR2(10) INDEX BY binary_integer;
 lt_selected_Records mytype;
 li_items_in_block ITEMS_IN_BLOCK;
BEGIN
 li_items_in_block(1) := 'TYPE';

 TABLE_FROM_BLOCK(lt_selected_records, <BlockName>, 1, all_records, li_item_in_block);
 FOR x IN 1..lt_selected_records.count
 LOOP
   IF lt_selected_records(x).TYPE = :type THEN
     Message('You Cannot Enter the Same Type of Device').
     RAISE FORM_TRIGGER_FAILURE;
   END IF;
 END LOOP;
TComandanteAuthor Commented:
Hello riazpk,
   In li_items_in_block(1) := 'TYPE' after the begin,  do I have to substitute 'TYPE' with variable in my block?

   Also after the LOOP,  If it_selected_records(x).TYPE = :type  -- Do I have to substitute (x).TYPE with my variable in the block?


    I have not used this, so I kind of confused.


Thanks,
Terry
         
riazpkCommented:
yes, 'TYPE' is the item name in block you want to check for duplication. So you will have to change this with your item name. For example, support your block name is blk1 and item name is itm1, then above code will look like:

DECLARE
 TYPE mytype is TABLE of VARCHAR2(10) INDEX BY binary_integer;
 lt_selected_Records mytype;
 li_items_in_block ITEMS_IN_BLOCK;
BEGIN
 li_items_in_block(1) := 'ITM1';

 TABLE_FROM_BLOCK(lt_selected_records, 'BLK1', 1, all_records, li_item_in_block);
 FOR x IN 1..lt_selected_records.count
 LOOP
   IF lt_selected_records(x).ITM1 = :BLK1.ITM1 THEN
     Message('You Cannot Enter the Same Type of Device').
     RAISE FORM_TRIGGER_FAILURE;
   END IF;
 END LOOP;
riazpkCommented:
If you could send me your email address i can forward you the sample form with an alternate.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TComandanteAuthor Commented:
Hi riazpk,
    My e-mail address is tcomandante@producerware.com


Thanks,
Terry
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.