Oracle
  Home arrow Oracle arrow Page 4 - Associative Arrays in Oracle PL/SQL: The Professional Approach
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
ORACLE

Associative Arrays in Oracle PL/SQL: The Professional Approach
By: Jagadish Chatarji
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 18
    2006-03-20


    Table of Contents:
  • Associative Arrays in Oracle PL/SQL: The Professional Approach
  • A professional approach to traversing an associative array using Oracle PL/SQL
  • Bottom to top traverse of an associative array using Oracle PL/SQL
  • Deleting individual elements in an associative array using Oracle PL/SQL
  • Deleting a set of elements in an associative array using Oracle PL/SQL

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Associative Arrays in Oracle PL/SQL: The Professional Approach - Deleting individual elements in an associative array using Oracle PL/SQL
    ( Page 4 of 5 )

    Until now, we simply added pairs of data to an associative array.  Now, we shall examine how to delete pairs of data from an existing associative array. 

    Let us consider the following code:

    declare
          type year_type is table of number index by binary_integer;
          year_profits      year_type;
          tot_profits number := 0;
          i           number;
    begin
          year_profits(1990) := 34000;
          year_profits(1991) := -45000;
          year_profits(1992) := 43000;
          year_profits(1996) := -13000;
          year_profits(1998) := 53000;

          i := year_profits.first;
          while i <= year_profits.last
          loop
                if year_profits(i) < 0 then
                      year_profits.delete(i);
                end if;
                i := year_profits.next(i);
          end loop;

          i := year_profits.first;
          while i <= year_profits.last
          loop
                tot_profits := tot_profits + year_profits(i);
                i := year_profits.next(i);
          end loop;
          dbms_output.put_line('Total profits: ' || tot_profits);
          dbms_output.put_line('No. of years in profit: ' ||
    year_profits.count);

    end;

    The highlighted part checks for any negative numbers within the values available in the associative array.  If anything is found, it gets deleted automatically using the DELETE member (which is also pre-defined).

    In the next section, we shall examine how to delete more than one element at a time.



     
     
    >>> More Oracle Articles          >>> More By Jagadish Chatarji
     

       

    ORACLE ARTICLES

    - Oracle's Turn to Play in the Sun
    - Implementing and Using Oracle`s Restore Poin...
    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek