returning array type from a function

From: ciapecki <ciapecki_at_gmail.com>
Date: Mon, 23 Mar 2009 03:01:30 -0700 (PDT)
Message-ID: <c6b555a9-813f-4fb9-a7bc-8f1f38a2c1e6_at_q9g2000yqc.googlegroups.com>



I am wondering why following returns
PLS-00382: expression is of wrong type

I declares in package specification

TYPE index_record is record (

    index_type varchar2(2) := 'BT',
    index_name varchar2(27) := '');

type assoc_array_index_recs is table of index_record index by PLS_INTEGER; In my procedure I declared:
ind_h assoc_array_index_recs;

in procedure body:
ind_h := mock_hash();

where mock_hash() is a function returning assoc_array_index_recs type: function mock_hash return assoc_array_index_recs is

    new_mock assoc_array_index_recs;
    new_rec index_record;
begin

    new_rec.index_name := 'abc';
    new_rec.index_type := 'aa';
    new_mock(1) := new_rec;
    new_rec.index_name := 'cde';
    new_rec.index_type := 'bb';
    new_mock(2) := new_rec;

    return new_mock;
end;

When I try to compile I get the error message from the beginning of this post.

When I replace the
ind_h := mock_hash(); -- in my procedure with:

new_rec.index_name := 'abc';
new_rec.index_type := 'aa';
new_mock(1) := new_rec;
new_rec.index_name := 'cde';
new_rec.index_type := 'bb';
new_mock(2) := new_rec;

ind_h := new_mock;

 after declaring new_rec and new_mock
 everything works fine

Does it mean my function mock_hash() cannot return the assoc_array_index_recs type?

is there any other array type that can be returned by a function?

thanks,
chris Received on Mon Mar 23 2009 - 05:01:30 CDT

Original text of this message