Peter, March 21, 2007 - 2:37 am UTC
Thanks
Peter
Associative Array
Siva, August 01, 2017 - 10:37 am UTC
Hi ,
Can you help me here.. i am trying to print 1st element of associative array. It is giving me the below error.
ORA-06550: line 18, column 1:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
Below is the block:
declare
type test_array is table of varchar2(10) index by number(10);
test_array_1 test_array;
i number(10);
begin
test_array_1(567):='a';
test_array_1(89):= 'b';
test_array_1(3):= 'c';
i:= test_array_1.first;
dbms_output.put_line( test_array_1(i) ); --just i want to print 1 element in the array
end;
August 01, 2017 - 2:05 pm UTC
The problem is way back in your type declaration:
declare
type test_array is
table of varchar2(10) index by number(10);
test_array_1 test_array;
begin
null;
end;
/
PLS-00315: Implementation restriction: unsupported table index type
You can't use number for the index type...
Processing with multiple attributes
Rajasekhar, June 01, 2020 - 3:08 pm UTC
Hello,
Can you please help in printing the multiple attribute of associate array.
When i am tried with below code getting no data found error as it is indexing the count of records. but actually it is indexed by a_rollno.
create table test2(a_id number(10),
a_name varchar2(30),
a_class varchar2(30),
a_rollno number(10));
insert into test2 values(1,'test','first',10);
insert into test2 values(2,'test1','second',20);
insert into test2 values(3,'test2','thgird',30);
insert into test2 values(4,'test3','four',40);
declare
type collection_test is table of test2%rowtype index by binary_integer;
collection_test1 collection_test;
cursor c_1 is select * from test2;
begin
for i in c_1
loop
collection_test1(i.a_rollno):=i;
end loop;
dbms_output.put_line('the count is '||collection_test1.count);
for i in c_test1.first .. c_test1.last
loop
dbms_output.put_line('the name is '||collection_test1(a_rollno).a_name);
end loop;
exception
when others then
raise_application_error(-20000,'The error is'||SQLERRM||' '||SQLCODE);
end;
/
Thanks
June 03, 2020 - 10:59 am UTC