?
Solved

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

Posted on 2006-03-29
5
Medium Priority
?
862 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        
0
Comment
Question by:TComandante
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:riazpk
ID: 16329497
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
 

Author Comment

by:TComandante
ID: 16332599
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
 
LVL 13

Expert Comment

by:riazpk
ID: 16353125
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
 
LVL 13

Accepted Solution

by:
riazpk earned 2000 total points
ID: 16353128
If you could send me your email address i can forward you the sample form with an alternate.
0
 

Author Comment

by:TComandante
ID: 16361075
Hi riazpk,
    My e-mail address is tcomandante@producerware.com


Thanks,
Terry
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Suggested Courses
Course of the Month16 days, 19 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question