I have a method that accepts int[] (userIDs) and an int (groupID) as parameters. Then it runs the stored procedure and insert the data into the DB
For example:
if userIDs=[1,2,3] and groupID=4,
then I want the following data to be inserted into the DB
userID groupID
1 4
2 4
3 4
I have 2 solutions to this problem. The first one is to write a stored procedure that insert a single record into the DB. In the method(), I will loop through the int[] and call the stored procedures n times
method()
for (int i =0; i< userID.length; i++){
// call stored procedure to insert a single record
}
The second solution is to pass int[] and int as parameters to the stored procedures and do the looping in the stored procedure.
Which way is a better solution? ( if its the 2nd solution is better, can someone provide guidance on handling int[] in stored procedure )