In the previous section, I deleted only individual elements. In this section, I shall introduce you to deleting a series of elements (pairs) in an associate array. Let us consider the following code: declare year_profits.delete(1991,1995); i := year_profits.first; dbms_output.put_line('Total profits: ' || tot_profits); end; Within the above code, you can understand that it removes all the elements (or pairs) from the associative array, which are in between the keys 1991 and 1995 (both inclusive). Summary Until now, I focused on using only BINARY_INTEGER based “keys” for the pairs that are going to be stored in the associative array. In fact, you can also try using all of these methods with VARCHAR2. When you work with a VARCHAR2 based indexed, it works very similar to a hash table. If we embed the whole code in a beautiful package, I am quite sure that it would help you a lot. We can further extend this with CURSORS, REF CURSORS, OBJECT TYPES, VARRAYS and so on. Even though I concentrated only on associative arrays, several of these methods should work with other types of PL/SQL tables as well. Go ahead and try it. In the next article in this series, I shall mix all these methods in a modular fashion and finally implement it in a reusable package. So be sure to check this website frequently! Any comments, suggestions, feedback, bugs, errors, enhancements are highly appreciated at jag_chat@yahoo.com
blog comments powered by Disqus |