array in stored procedure

Can i declare an array of varchar in a stored procedure or use a structure but calling the structure fields using their position in the structure instead of the name?
LVL 6
DaniProAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
To answer the first part:  Yes

declare
      type arrType is table of varchar2(50);
      myarr arrType;
begin
      myarr := arrType('a','b');
      dbms_output.put_line('First: ' || myarr(1));
      dbms_output.put_line('Second: ' || myarr(2));
end;
/


I'm not clear what you are asking on the second part.
DaniProAuthor Commented:
Thank's for your replay, but i need to valorize my array with the field number.
Can i use a syntax like this?
myarr(1) := 'a'
myarr(2) := 'b'
slightwv (䄆 Netminder) Commented:
You will first need to initialize the array.  If you don't know the limit at runtime, you can extend it as needed:

declare
      type arrType is table of varchar2(50);
      myarr arrType;
begin

      myarr := arrType(null);
      myarr(1) := 'a';
      myarr.extend(1);
      myarr(2) := 'b';

      dbms_output.put_line('First: ' || myarr(1));
      dbms_output.put_line('Second: ' || myarr(2));
end;
/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.