Click here to Skip to main content
15,883,710 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am having query as follows which will get multiple data at a time but i am not knowing how to write a store procedure for this can any one help me
This is my query

Select File_Data from tblachmaster WHERE Id IN (1,2,3, and so on);


As from my code i has to pass i would like to declare a variable in stored procedure and has to execute as per i needed

This is my code


string deleteSQL = "Select File_Data from tblachmaster WHERE Id IN (" + gvIDs.Substring(0, gvIDs.LastIndexOf(",")) + ")";


This instead of writing like this i have to use store proc to execute
Posted
Updated 24-Apr-11 22:29pm
v3

1 solution

I hope you are aware of how to write SP in mysql .

Here is the logic for your query please do sandwitch this in SP.

SQL
SET @test = Select File_Data from tblachmaster WHERE Id IN (' + @ConditionVar + ')';
PREPARE stmt FROM @test;
EXECUTE stmt;


If you need more help give me some more time I will give you exact SP.
But please let me know the result of above solution.
 
Share this answer
 
v3
Comments
demouser743 25-Apr-11 4:26am    
Hey through code i am getting this but as per in store proc i am not aware how to create the exact as per i needed
RDBurmon 25-Apr-11 4:28am    
Do you know How to create Proc in SP with parameter and use that parameter in SP code. ?
demouser743 25-Apr-11 4:29am    
Ya i know that
demouser743 25-Apr-11 4:30am    
CREATE DEFINER=`root`@`%` PROCEDURE `usp_SelectFileData`(_Id varchar(100))
BEGIN
Select File_Data from tblachmaster WHERE Id IN (_Id);
END
demouser743 25-Apr-11 4:30am    
But if i write like this i can not pass multiple values here right

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900