Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sql

mysql

plsql

I tried with the below code but its throwing an error.

DECLARE TYPE INPUTVALUES IS VARRAY(5) OF VARCHAR(10);

Is ther a way to declare array variables inside the stored procedure.

like image 908
Gowtham Ramamoorthy Avatar asked Jan 17 '26 03:01

Gowtham Ramamoorthy


1 Answers

As far as I know relational databases don't have arrays. They usually work on scalar values.

Is there a way to declare array variables inside the stored procedure.

This is more or less broad as to what you are trying to achieve. An example as to how you can achieve an array sort of thing can be like:

SET @myArray = 'test1,test2,test3'; -- Treat it like an array

SELECT * FROM myTable
WHERE FIND_IN_SET (columnName, @arr);

(This is for MySQL)

like image 164
Rahul Tripathi Avatar answered Jan 19 '26 20:01

Rahul Tripathi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!