Home » Developer & Programmer » Forms » *** Problem with tabuler form ***
*** Problem with tabuler form *** [message #82555] Sun, 08 June 2003 00:10 Go to next message
Robin ( Bangladesh)
Messages: 25
Registered: September 2002
Junior Member
Experts,
I have a tabuler form for product sales having coloum P_code,qty. I want to protect double entry of same same product. How can I do it when user entering product ? Pls help me.

Thank in advance.

Robin
Re: *** Problem with tabuler form *** [message #82562 is a reply to message #82555] Tue, 10 June 2003 00:19 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Here's an example from Metalink. It prevents entering a duplicate EMPNO in the EMP table. The code is to be placed in the WHEN-VALIDATE-ITEM trigger of EMPNO:
Declare
  cnt       number;
  rg_name   VARCHAR2(40) := 'dup_empno';
  rg_col1   VARCHAR2(20) := 'NumCol';
  rg_id     RecordGroup;
  gc_id     GroupColumn;
  rowcount  NUMBER;
  row_value NUMBER;
begin
  Select count(*)
  into cnt 
  from emp 
  where empno =:empno;
	 
  If cnt = 0 then 	   /* create a record group dynamically */ 	
    rg_id := Find_Group(rg_name);
	 	
    IF Id_Null(rg_id) THEN
      rg_id := Create_Group(rg_name);
      gc_id := Add_Group_Column(rg_id,rg_col1,NUMBER_COLUMN);
    END IF;
	 	
    Add_Group_Row( rg_id, END_OF_GROUP );
    rowcount :=  get_group_row_count(rg_id);
    gc_id    :=  Find_column('dup_empno.NumCol');
	 	
    set_group_number_cell(gc_id,rowcount,to_number(:system.cursor_value));
	 	
    FOR i IN 1 .. get_group_row_count(rg_id)-1
    LOOP
      row_value :=get_group_number_cell(gc_id,i);
      IF row_value = :empno  THEN
        DELETE_GROUP_ROW(rg_id,rowcount);
        Message('already exists');
        RAISE form_trigger_failure;
      END IF;
    END LOOP;
  ELSE
    Message('Data is already exists in DATABASE');
    Raise form_trigger_failure;
  END IF;
END; 
You can modify this code to fit your needs.

HTH,
MHE
Re: *** Problem with tabuler form *** [message #82628 is a reply to message #82562] Fri, 13 June 2003 23:23 Go to previous message
Robin ( Bangladesh)
Messages: 25
Registered: September 2002
Junior Member
Friend,
Thanks trying to help me. Your provided code will protect double entry during insertion into table, but I need restriction during entry in form. i.e. when user going to create next_record in tabuler form if this product code already in tabuler form cursor will not go to next_record.

Robin.
Previous Topic: Locking Problem
Next Topic: query regarding records per page in matrix report
Goto Forum:
  


Current Time: Fri Mar 29 01:07:26 CDT 2024