Saturday, September 01, 2007

small sorting example in oralce pl/sql

PROCEDURE prc_test(a VARCHAR2)
IS
TYPE v_test IS TABLE OF VARCHAR2(2) INDEX BY VARCHAR2(2);
v_v_test v_test;
i VARCHAR2(2);
BEGIN
v_v_test('AB') := 'A';
v_v_test('AA') := 'C';
v_v_test('BA') := 'B';
--DBMS_OUTPUT.PUT_LINE('test .... ' || v_v_test.COUNT);
--DBMS_OUTPUT.PUT_LINE('test .... ' || v_v_test.FIRST);
--DBMS_OUTPUT.PUT_LINE('test .... ' || v_v_test.LAST);
-- DBMS_OUTPUT.PUT_LINE('test .... ' || v_v_test.NEXT(1));
-- DBMS_OUTPUT.PUT_LINE('test .... ' || v_v_test.NEXT(2));
i := v_v_test.FIRST; -- get subscript of first element
DBMS_OUTPUT.PUT_LINE('test .... ' || i);
WHILE i IS NOT NULL LOOP
-- do something with courses(i)
i := v_v_test.NEXT(i); -- get subscript of next element
DBMS_OUTPUT.PUT_LINE('test .... ' || i);
END LOOP;

NULL;
END;

Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Comments [Atom]