Search code examples
oracle-databaseoracle11goracle10goracleformsoracle-fusion-middleware

How to automatic increment in number on Button SET_ITEM_PROPERTY


I have Button called "UPLOAD" on Oracle Forms. When press the "UPLOAD" button then 2 Processes will run.

Process 1:

-- Upload data from Excel File into Oracle forms

-- Save data From Oracle Forms to Database Table

-- Show duplicate records on Data Block

-- Button Lable will be change with UPLOAD[1]

If again press the "UPLOAD" Button Then Process 2 Will run

Process 2:

-- Upload data from Excel File into Oracle forms

-- Save data From Oracle Forms to Database Table

-- Button Lable will be change with UPLOAD[2]

Now I want When again press "UPLOAD" button then automatic increment in number. Like UPLOAD[3] and so on.

Code of "UPLOAD" Button:

IF ( :WE_GROUP.FILE IS NOT NULL ) AND :WE_GROUP.DISPLAY IS NOT NULL THEN
 EXCEL_UPLOAD;
 commit;
 Set_Item_Property('Upload',label,'Upload'||' ['||2||']');
 :WE_GROUP.FILE := NULL;

ELSIF ( :WE_GROUP.FILE IS NOT NULL ) AND :WE_GROUP.DISPLAY IS NULL THEN
 EXCEL_UPLOAD;
 commit;
 Set_Item_Property('Upload',label,'Upload'||' ['||1||']');
 :WE_GROUP.DISPLAY := 1;
 :WE_GROUP.FILE := NULL;

go_block('we_group_hof_k');
CLEAR_BLOCK(NO_VALIDATE);

go_block('we_group_hof_k');
 first_record;
  for c in
      (
       SELECT cnicno, hofid
         FROM hof 
        WHERE cnicno IN (SELECT cnic_no FROM we_group_hof_k)
      )     
  loop
:we_group_hof_k.CNIC_NO := c.cnicno;
:we_group_hof_k.GROUP_HOF_ID := c.hofid;
 next_record;
  end loop;

ELSE
    Message('No File selected.');
    message(' ');
    RAISE Form_Trigger_Failure;

END IF;

Solution

  • Just declare a local integer variable as

    declare
       v_label  pls_integer
    begin
    

    and assign a value incremented starting from the integer value seen on the Upload button

    v_label := regexp_replace(Get_Item_Property('Upload',label),'(\D)')+1 
    

    and then replace

    Set_Item_Property('Upload',label,'Upload'||' ['||2||']');
    

    with

    Set_Item_Property('Upload',label,'Upload ['||v_label||']');