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?
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.

PortletPaulfreelancerCommented:
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)
1
Ryan ChongCommented:
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

0
Vikas GargBusiness Intelligence DeveloperCommented:
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
0

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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Ryan ChongCommented:
@Gowtham Ramamoorthy, glad that you found the solution cheers
0
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.
0
Ryan ChongCommented:
@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.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.