Plsql Collection Data Deletion

PLSQL collection data deletion

Preview

CREATE OR REPLACE TYPE l_rec_type IS OBJECT (id NUMBER, name VARCHAR2 (1111));
/
CREATE OR REPLACE TYPE l_tab_type IS TABLE OF l_rec_type;
/
DECLARE
    l_tab     l_tab_type := l_tab_type ();
    l_check   NUMBER;
BEGIN
    l_tab := l_tab_type (NULL, NULL);
    l_tab (1) := l_rec_type (1000, 'ashish');
    l_tab (2) := l_rec_type (2000, 'sahay');
    FOR i IN l_tab.FIRST .. l_tab.LAST
    LOOP
        IF l_tab (i).id = 1000
        THEN
            l_tab.delete (i);
            l_tab (i) := NULL;
        END IF;
        DBMS_OUTPUT.put_line (l_tab (i).id);
        DBMS_OUTPUT.put_line (l_tab (i).name);
    END LOOP;
END;
/

Preview

You might Also like:


comments powered by Disqus