SERPland Blog

Oracle PL/SQL: VARRAY (Collection) manual filling and reading for processing

· 465 words · 3 minutes to read

With Oracle and PL/SQL you can use the COLLECTION features. Simply fill in data into a VARRAY and also read it out.

See follwing simple PL/SQL example here:

declare type r_rec is record( cont_id number ,macc_id number ); type t_v is varray(100000) of r_rec; –mail_idx%rowtype; t_tab t_v := t_v(); – procedure ext(i_cont_id in number, i_macc_id in number) is l_new number; begin –dbms_output.put_line(’t_tab.last :’ ||t_tab.last); l_new := nvl(t_tab.last,0)+1; t_tab.extend; t_tab(l_new).cont_id := i_cont_id + l_new; t_tab(l_new).macc_id := i_macc_id + l_new; end; begin dbms_output.put_line(’———————’);

-- fill in varray, for example with only two rows ext(i_cont_id=>44444, i_macc_id=>33333); ext(i_cont_id=>55555, i_macc_id=>66666);

-- varray processing for i in 1..t_tab.count loop dbms_output.put_line(t_tab(i).cont_id); end loop; end;


Update 2024

Update on Oracle PL SQL VARRAY Collection Manual Filling and Reading 🔗

The information provided in the 2011 text about Oracle PL SQL and VARRAY collections is still valid for the years 2021 to 2024. Oracle and PL SQL continue to offer the capability to fill data into a VARRAY and read it out for processing.

However, there have been advancements and updates in Oracle technology over the years. In 2024, Oracle PL SQL has seen improvements in performance, security, and usability. The language has evolved to provide better support for handling complex data structures, making it easier for developers to work with VARRAY collections.

One significant update in Oracle technology is the introduction of Autonomous Database, which offers a fully managed, self-driving database service. This cloud-based solution automates database management tasks, allowing developers to focus more on application development rather than infrastructure maintenance.

Additionally, Oracle has continued to enhance its PL SQL programming language with new features and optimizations. Developers now have access to more robust tools and libraries to streamline the development process and improve code efficiency.

In terms of the VARRAY collection, developers can still use the same techniques to fill in data and process it in Oracle PL SQL. The example provided in the 2011 text showcases a simple PL SQL script for filling a VARRAY with two rows of data. This basic functionality remains consistent in the current years.

Overall, while the core concepts of Oracle PL SQL and VARRAY collections remain the same, the technology has advanced significantly in terms of performance, automation, and developer experience. Developers working with Oracle databases in 2024 can take advantage of these advancements to build more efficient and secure applications.

With the continuous improvement of Oracle technologies, developers can expect further enhancements in PL SQL and VARRAY processing capabilities in the years to come.

In conclusion, the foundational information about Oracle PL SQL VARRAY collections for manual filling and reading is still applicable in 2024, with updates reflecting the advancements in Oracle technology. Developers are encouraged to stay updated on the latest features and best practices to make the most of Oracle’s powerful database solutions.