Link to home
Start Free TrialLog in
Avatar of Gowtham Ramamoorthy
Gowtham Ramamoorthy

asked on

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);
Avatar of PortletPaul
PortletPaul
Flag of Australia image

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)
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

ASKER CERTIFIED SOLUTION
Avatar of Vikas Garg
Vikas Garg
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Gowtham Ramamoorthy, glad that you found the solution cheers
Avatar of Gowtham Ramamoorthy
Gowtham Ramamoorthy

ASKER

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