What are you really trying to accomplish?The whole idea behind using a pl/sql collection is that you fetch a lot of data into a memory structure in the database and then you do something with that data.
You can't access anything in a pl/sql collection until you put data in it, which means select * bulk collect into. For the code you wrote you might as well have used a cursor. Take a look at the doc and think about what you need and you should be able to come up with something better.
http://download.oracle.com/docs/cd/B...olls.htm#34607
Code:DECLARE lcount NUMBER; TYPE emp_name IS Varray(1000) OF VARCHAR2(40); emp emp_name; user_name VARCHAR2(200); BEGIN SELECT userid BULK COLLECT INTO emp FROM SUSERIDTABLE WHERE "UserID" LIKE 'karthik.%'; IF(emp.COUNT > 0) THEN FOR i IN 1..lcount LOOP user_name := emp(i) || 'and'; dbms_output.put_line('The GetValue with value ' || user_name); END LOOP; END IF; END; /




The whole idea behind using a pl/sql collection is that you fetch a lot of data into a memory structure in the database and then you do something with that data.
Reply With Quote