This discussion is archived
2 Replies Latest reply: Mar 29, 2013 6:25 AM by 968357 RSS

moving list values from one to another

968357 Newbie
Currently Being Moderated
Hello Dear,
I want to let user to move list value from one list to another empty list on a button click.
i have populated one list dynamically on * when new form instance trigger.*
i m trying following code on button click..


i have to move the element form SA list box to SI list box.

declare
     n1 number:=0;
     n2 number:=0;
     list_label varchar2(50);
     LIST_VALUE CHAR(5);
     v varchar2(25);
     
begin
     n1:=get_list_element_count('DTL.SA');
     n2:=get_list_element_count('DTL.SI');
       IF N2 IS NULL THEN N2:=0; END IF;
    IF N1 IS NULL THEN N1:=0; END IF;
    
     IF N1>=1 THEN
     if :DTL.SA is not null then
          LIST_VALUE:=:DTL.SA;
             FOR I IN 1..N1
                loop
       v:=get_list_element_VALUE('DTL.SA',i);
       if v=LIST_VALUE then
            LIST_LABEL:=get_list_element_LABEL('DTL.SA',i);
        delete_list_element('DTL.SA',i);
       end if;
                end loop;
                add_list_element('DTL.SI',n2+1,LIST_LABEL,LIST_VALUE);
     END IF;
     END IF;
end;
when i run a form & select a value from in-between position of a list and press the button it gives a message like *"LIST ELEMENT OUT OF INDEX"* and also move the value to another list.

when i simply press button without selecting any of the values in list,it will insert a blank item in another list...


please tell me how to overcome this problem..

m waiting..

thanks for any reply..


With regards
Vishal agrawal
  • 1. Re: moving list values from one to another
    GregorM Explorer
    Currently Being Moderated
    Hi.

    I think the problem with your code is you have to exit loop when list element is deleted. Doing this way you can also put add_list_element inside loop statement. This will also eliminate the second problem when blank value is added.
    ...
      FOR I IN 1..N1
        loop
          v:=get_list_element_VALUE('DTL.SA',i);
          if v=LIST_VALUE then
                LIST_LABEL:=get_list_element_LABEL('DTL.SA',i);
            delete_list_element('DTL.SA',i);
            add_list_element('DTL.SI',n2+1,LIST_LABEL,LIST_VALUE); --transfer value inside loop
            exit; -- exiting loop when element found
          end if;
      end loop;
    ...
    Best regards
  • 2. Re: moving list values from one to another
    968357 Newbie
    Currently Being Moderated
    thanks for ur reply..

    this solve my problem


    with regards
    vishal agrawal

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points