We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

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

TComandante
TComandante asked
on
Medium Priority
887 Views
Last Modified: 2008-01-09
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        
Comment
Watch Question

Ora_TechieDatabase Administrator
CERTIFIED EXPERT

Commented:
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;

Author

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
         
Ora_TechieDatabase Administrator
CERTIFIED EXPERT

Commented:
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;
Database Administrator
CERTIFIED EXPERT
Commented:
If you could send me your email address i can forward you the sample form with an alternate.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Hi riazpk,
    My e-mail address is tcomandante@producerware.com


Thanks,
Terry
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.