• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 865
  • Last Modified:

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        
0
TComandante
Asked:
TComandante
  • 3
  • 2
1 Solution
 
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;
0
 
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
         
0
 
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;
0
 
riazpkCommented:
If you could send me your email address i can forward you the sample form with an alternate.
0
 
TComandanteAuthor Commented:
Hi riazpk,
    My e-mail address is tcomandante@producerware.com


Thanks,
Terry
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now