Till now to work with more than one row in PL/SQL, we are using a BULK COLLECT together with TABLE type of variable. But there is another powerful way of doing the same without using any of the above two. Let us consider a very simple example as following: begin A wonder? Yes! You can directly use a FOR loop with a SELECT inside it without using any complicated structures. It is also called as a FOR loop with inline SELECT statement. This is really a very powerful technique of doing things very fast, without even really thinking about any declarations or any such nonsense. You can also simplify the above complicated program a bit as following: declare The above program removed several statements of declarations and even a SELECT also. Not only that, this also looks very simplified in terms of readability. We shall discuss in my up-coming articles about the pros and cons of each approach, but not yet. The reason we must wait is that I need to cover another powerful topic called as CURSOR (which also does the same as above and bit more too). After completing the explanations of all approaches, then it would be best to discuss the pros and cons of each and every approach in comparison with other approaches. I hope you do agree with me.
blog comments powered by Disqus |