IS it possible to declare a array variable inside a stored procedure of SQL ?

I tried with the below code but its throwing an error.
DECLARE TYPE INPUTVALUES IS VARRAY(5) OF VARCHAR2(10);
Gowtham RamamoorthyAsked:
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.

PortletPaulEE Topic AdvisorCommented:
Exactly what language context are you using that code in please?

VARCHAR2 is an Oracle data type (not avaliable in mssql) but you have chosen 3 MSSQL topics


Oh. and if anything throws an error please include the FULL text of that error (error code and any explanation)
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
you can try declare it as a Table:
declare @arr table(v VARCHAR(10))

insert into @arr(v) values ('2421')
insert into @arr(v) values ('1531')
insert into @arr(v) values ('7721')
insert into @arr(v) values ('9421')
insert into @arr(v) values ('1051')

select * from @arr

Open in new window

Vikas GargAssociate Principal EngineerCommented:
Hello,

You can not declare an array but you can declare table variable in the SQL stored procedure which would work for you.

DECLARE @ArrayTable Table (Col1 int, Col2 Varchar(50))

Hope this will help you.
Or if you need further help explain with example why you need to declare array inside Stored Procedure

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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
@Gowtham Ramamoorthy, glad that you found the solution cheers
Gowtham RamamoorthyAuthor Commented:
Thanks Ryan. But actually I have just started to code a procedure. I dont know how deep the rabbit hole goes. Need your help for sure.
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
@Gowtham Ramamoorthy, I just want to highlight one thing...

It seems you're quite new to this site, but what I mean is that my suggestion is same as what Vikas Garg had proposed, is there any reason why you accepted his suggestion but not give a same fair grade to my suggestion as well? it seems that both of us posted within an interval of 1 min but my suggested was posted first.
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
Databases

From novice to tech pro — start learning today.