|
|
|
Re: how to delete list eliment when u dont know index number [message #86420 is a reply to message #86415] |
Tue, 28 September 2004 22:33 |
Himanshu
Messages: 457 Registered: December 2001
|
Senior Member |
|
|
Hi Ashsih,
Sorry I gave you code for Deleting Tree Node from a Tree item.
Here is a code for List items:
/*
** Built-in: GET_LIST_ELEMENT_COUNT
** Example: Add an element to the list item. Before adding
** the element, verify that the element is not in
** the current list.
*/
DECLARE
total_list_count NUMBER(2);
loop_index_var NUMBER(2) := 1;
list_element VARCHAR2(50);
list_element_value VARCHAR2(50);
list_element_to_add VARCHAR2(50);
list_value_to_add VARCHAR2(50);
element_match VARCHAR2(5) := 'TRUE';
value_match VARCHAR2(5) := 'TRUE';
BEGIN
/*
** Determine the total number of list elements.
*/
total_list_count := Get_List_Element_Count(list_id);
/*
** Compare the current list item elements with the element that
** needs to be deleted.
*/
LOOP
list_element := Get_List_Element_Value(list_id,
loop_index_var);
loop_index_var := loop_index_var + 1;
IF list_element_to_add = list_element THEN
element_match := 'FALSE';
END IF;
EXIT WHEN list_element = list_element_to_add OR
loop_index_var = total_list_count;
END LOOP;
/*
** Compare the current list item values with the value that
** will be added.
*/
loop_index_var := 1;
LOOP
list_element_value:= Get_List_Element_Value(list_id,
loop_index_var);
loop_index_var := loop_index_var + 1;
IF list_value_to_add = list_element_value THEN
value_match := 'FALSE';
END IF;
EXIT WHEN list_element_value = list_value_to_add OR
loop_index_var = total_list_count;
END LOOP;
/*
** Add the element and value if it is not in the current list
*/
IF element_match AND value_match = 'TRUE' THEN
DELETE_List_Element(list_id, loop_index_var);
END IF
END;
HTH
Regards
Himanshu
|
|
|