You are on page 1of 1

Prior to Oracle9i Database, you could use BULK COLLECT only with static SQL.

N ow you can use BULK COLLECT with both dynamic and static SQL. You can use BULK COLLECT keywords in any of the following clauses: 1) SELECT INTO. 2) FETCH INTO 3) RETURNING INTO. A collection populated by BULK COLLECT is always filled sequentially from in dex value 1 (or is empty). If you are BULK COLLECTing into a varray or a nested table, you do not need to initialize or extend prior to executing the BULK COLLECT query. Oracle will t ake care of all of that for you. SELECT...BULK COLLECT will not raise NO_DATA_FOUND if no rows are found. Ins tead, you must check the contents of the collection to see if there is any data inside it. If the query returns no rows, the collection s COUNT method will return 0. As with any operation involving collections, use of BULK COLLECT will likely increase the amount of PGA (Process Global Area) memory used by an application session. Use the LIMIT clause with BULK COLLECT to put a cap on the amount of PGA mem ory used by your query. You can specify the limit (example in next section) as a literal, expression or parameter. I suggest you avoid hard-coding the value. 100 is a good default or starting value for LIMIT. Setting the value higher, to say 500 or 1000, will probably not improve performance significantly, but wi ll increase PGA consumption. For very large volumes of data, such millions of ro ws of data, you should probably experiment with higher limit values to see what kind of impact you see. You can fetch into a single collection of records or a series of collections (one for each expression returned in the SELECT list).

You might also like