By "array" I assume you are referring to a PL/SQL table. In this case, I would define a cursor to select the distinct titles, then loop through the cursor to load the values into the PL/SQL table.
CURSOR title_cursor IS SELECT DISTINCT title FROM my_table;
TYPE ttable IS TABLE OF my_table.title%TYPE INDEX BY BINARY_INTEGER;
title_table TTABLE;
BEGIN
FOR t IN title_cursor LOOP
title_table(title_cursor%ROWCOUNT) := t.title;
END LOOP;
END;
Actually I am trying to avoid creating a table. This is part of a vb 6.0 application. I have a table that I would like to select one column of information into an array, not a PL/SQL table. After I insert the distinct titles into the array I want to the use the array in a for loop to take each distinct title and run in through a list of conditions, and then go to the next distinct title, until the end is reached.
I am not sure that a cursor is right for this, but then again I don't know much about cursors.
Though Cursors are discouraged but this seems a perfect candidate for use of cursors. If its a really huge table then may be some other way needs to be foud out because in such a case cursor would make it slow.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.