This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass an Integer Array to a Stored Procedure in mysql?

 
Shifali Rana
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to pass the Stored Procedure "1,2,3" as a Integer Array, is this possible in mysql?

Actually I have to do
select * FROM User WHERE id IN (1,2,3);
I want to pass the Stored Procedure "1,2,3" as a Integer Array

If i use varchar then sometimes the query executes fine But, sometimes it gives no records.


Thanks


 
Agador Paloi
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could parse the string of numbers , such as '10,20,30' into an array of integers with a function you write using
substr and instr functions. I am not sure if that is what you are talking about.


Agad
 
Shifali Rana
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks Agad

Can you please give some example of a procedure that passes an integer array.
What i know is that we have to create a temporay table which contains the value that we have to pass to where clause.


Is it the only way to create an integer array in mysql?

Shifali
 
Agador Paloi
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to create a type that is a table of integers ( an array of integers type)


Then use it as a type for your function or procedure


should work
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic