Oracle Stored Procedure returned array method

Source: Internet
Author: User

Method for returning an array from an oracle stored procedure:

1. Create a package

Create or replace package test is

TYPE filename_array is table of varchar2 (1 );

Filename filename_array;

End test;

2. Create a stored procedure

Create or replace procedure test_array (v_cfjg out test. filename_array) is

Begin DECLARE I number;

D_cfjg dic_cfjg % rowTYPE;

D_nr dic_cfjg % rowTYPE;

Cursor c1 is SELECT * FROM dic_cfjg;

BEGIN

I: = 0;

V_cfjg: = test. filename_array (); -- array Initialization

Open c1;

LOOP fetch c1 into D_cfjg;

Exit when c1 % NOTFOUND;

I: = I + 1;

V_cfjg.EXTEND;

DBMS_OUTPUT.PUT_LINE (TO_CHAR (D_cfjg.dm ));

V_cfjg (v_cfjg.count): = D_cfjg.dm;

DBMS_OUTPUT.PUT_LINE (v_cfjg (v_cfjg.count ));

Test

FETCH C1 INTO D_cfjg;

Exit when c1 % NOTFOUND;

End loop;

End;

EXCEPTION

WHEN TOO_MANY_ROWS THEN

DBMS_OUTPUT.PUT_LINE ('too _ MANY_ROWS ');

When others then DBMS_OUTPUT.PUT_LINE (sqlerrm );

The methods for returning arrays from the oracle stored procedure will introduce the two methods mentioned above. If you have a better solution, share it with everyone. Don't swallow it by yourself. Finally, I hope the content above will help you.

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.