Oracle Stored Procedure exercise seven array topics

Source: Internet
Author: User

Nonsense written in front

Since the work needs to be frequently used in Oracle stored procedures, arrays are an inevitable element, so let's take a look at how Oracle stored procedures use arrays to a low level ....

The array is a data type. You need to create and declare the following statements.

 
Create Or ReplaceType myvarray_listAsVarray (10)Of Varchar2(50)

1. The array is used as the input parameter of the process.

 

 Create   Or   Replace   Procedure  Show_list_p ( /*  Used to display Arrays  */  P_varlist  In  Myvarray_list)  Is  Begin   For X In   1 ... P_varlist. Count  Loop dbms_output.put_line (  '  P_varlist (  ' | X |  '  ) =  '  |  P_varlist (x ));  End  Loop;  End ;
 --CallCall show_list_p (myvarray_list ('Oracle','DB2','SQL Server','MySQL','DBA'));

 

2 array as function return value

 Create   Or   Replace  Function Output_list_p Return  Myvarray_list  --  Variable arrays are called as output parameters in PL/SQL stored procedures:  As  O_data myvarray_list:  =  Myvarray_list ();  Begin    For V_count In   1 .. 5 Loop o_data.extend; o_data (v_count ):  =  V_count;  --  Dbms_output.put_line ('list ('| v_count |') = '| o_data (v_count ));      End  Loop;  Return  O_data;  End Output_list_p;
 --  Call  Declare  V_list myvarray_list; v_count  Number ;  Begin  Select Output_list_p () Into V_list From  Dual;  For V_count In   1 ... V_list. Count  Loop dbms_output.put_line (  '  V_list (  '  | V_count|  '  ) =  '  |  V_list (v_count ));  End  Loop;  End ;

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.