Home » Developer & Programmer » Forms » to check values in multirecord
to check values in multirecord [message #128853] Wed, 20 July 2005 23:13 Go to next message
manjuvasu
Messages: 22
Registered: May 2005
Junior Member
hello,

this is in forms. i have created a multirecord.while entering the values i have to check whether the previous record is same or not.how to do it.
Re: to check values in multirecord [message #128909 is a reply to message #128853] Thu, 21 July 2005 03:15 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
Hi,
Create a dynamic record group and add the values in post query and when validate record.
and check for duplication in when validate record.

by
vamsi
Re: to check values in multirecord [message #129072 is a reply to message #128909] Thu, 21 July 2005 18:00 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Nice answer ... beats doing a POST and then checking the database or looping through the block checking each record.

David
Re: to check values in multirecord [message #129089 is a reply to message #129072] Thu, 21 July 2005 23:06 Go to previous messageGo to next message
manjuvasu
Messages: 22
Registered: May 2005
Junior Member
hi,
this is not a database record.just while inputting the values like say, i am entering ename in multirecord-
ename
------
antony
bharat
catherine
antony ------>this name should not be repeated.here i have to check that the name is already entered.

how to ?
Re: to check values in multirecord [message #129269 is a reply to message #129089] Fri, 22 July 2005 23:46 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
then you need to use only when-validate-item and when-create-record.

1. set a flag in when-create-record.
2. if the flag is set check the record group for the duplication
if it is already there
raise an error
else
insert these values also into record group
unset the flag.
else /* flag is not set*/
do nothing.



by
vamsi
Re: to check values in multirecord [message #129270 is a reply to message #129269] Sat, 23 July 2005 00:33 Go to previous messageGo to next message
pradeep_davis
Messages: 14
Registered: July 2005
Junior Member
call this procedure when_create_record trigger

PROCEDURE dup_record
     (blk_name  VARCHAR2,
      col1      VARCHAR2,
      col2      VARCHAR2 DEFAULT NULL,
      col3      VARCHAR2 DEFAULT NULL,
      col4      VARCHAR2 DEFAULT NULL,
      col5      VARCHAR2 DEFAULT NULL,
      lbl_text  VARCHAR2 DEFAULT NULL)
IS
  rg_id        recordgroup;
  rg_name      VARCHAR2(20) := 'Dupval';
  rg_col       groupcolumn;
  error        NUMBER;
  reco_offset  NUMBER;
  col_val1     VARCHAR2(200);
  col_val2     VARCHAR2(200);
  colval       VARCHAR2(1000);
  len          NUMBER;
BEGIN
  rg_id := Find_group(rg_name);
  
  IF  NOT Id_null(rg_id) THEN
    Delete_group(rg_id);
  END IF;
  
  rg_id := Create_group(rg_name);
  
  rg_col := Add_group_column(rg_id,
                             'Columnchar',
                             char_column,
                             200); --if :system.form_status ='CHANGED' THEN
  
  Go_block(blk_name);
  
  IF form_success THEN
    last_record;
    
    reco_offset := :system.cursor_record;
    
    first_record;
    
    FOR i IN 1.. reco_offset LOOP
      Go_record(i);
      
      Add_group_row(rg_id,
                    end_of_group);
      
      colval := '';
      
      IF (col1 IS NOT NULL ) THEN
        colval := colval || Name_in(blk_name || '.' || col1);
      END IF;
      
      IF (col2 IS NOT NULL ) THEN
        colval := colval || Name_in(blk_name || '.' || col2);
      END IF;
      
      IF (col3 IS NOT NULL ) THEN
        colval := colval || Name_in(blk_name || '.' || col3);
      END IF;
      
      IF (col4 IS NOT NULL ) THEN
        colval := colval || Name_in(blk_name || '.' || col4);
      END IF;
      
      IF (col5 IS NOT NULL ) THEN
        colval := colval || Name_in(blk_name || '.' || col5);
      END IF;
      
      Set_group_char_cell(rg_col,
                          i,
                          colval);
    END LOOP;
    
    len := Get_group_row_count(rg_id);
    
    FOR i IN 1.. len LOOP
      col_val1 := Get_group_char_cell(rg_col,
                                      i);
      
      FOR j IN (i + 1).. len LOOP
        col_val2 := Get_group_char_cell(rg_col,
                                        j);
        
        IF col_val1 = col_val2 THEN
          IF (lbl_text IS NULL ) THEN
            error := Happ_msgs('E061',
                               'MREC',
                               blk_name);
          ELSE
            error := Happ_msgs('E061',
                               'MREC',
                               lbl_text);
          END IF;
          
          Go_record(j);
          --GO_RECORD(RECO_OFFSET);
          
          fail;
        END IF;
      END LOOP;
    END LOOP;
    
    Go_record(reco_offset);
  END IF;
END;


Upd-mod: Reformat code

[Updated on: Thu, 13 October 2005 01:43] by Moderator

Report message to a moderator

Re: to check values in multirecord [message #130098 is a reply to message #129270] Thu, 28 July 2005 03:03 Go to previous messageGo to next message
manjuvasu
Messages: 22
Registered: May 2005
Junior Member
hi,
i got the answer in a simpler way.
thanks
Re: to check values in multirecord [message #130110 is a reply to message #130098] Thu, 28 July 2005 03:55 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
can you share with us?

by
vamsi
Re: to check values in multirecord [message #130120 is a reply to message #130110] Thu, 28 July 2005 05:00 Go to previous message
manjuvasu
Messages: 22
Registered: May 2005
Junior Member
hi,
i have two items t1 and t2 as multirecord.in key-next-item trigger of t1,the following codings has been written.

declare
    a number;
    s varchar2(20);
    c varchar2(20);
begin
     a := get_block_property('blkname',current_record);
     if a=1 then
      go_item('blkname.t2');
     else
       s := :system.current_value;
       go_block('blkname');
       first_record;
       for i in 1..a-1 loop
        if s = :blkname.t1 then
         message('Duplicate');
         c := get_message;
        end if;
        next_record;
       end loop;
       last_record;
       go_item('blkname.t2');
     end if;
     if c = 'Duplicate' then
       go_item('blkname.t1');
     end if;
end;

check it out and reply me.

Upd-mod: Add code tags

[Updated on: Thu, 13 October 2005 01:44] by Moderator

Report message to a moderator

Previous Topic: Sending alerts to all application users
Next Topic: record groups
Goto Forum:
  


Current Time: Thu Sep 19 23:17:55 CDT 2024