Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have a form with dropdownlist containing fieldnames like firstname, lastname
I have a textbox to type the keyword.
According to the fieldname selected in dropdown and the keyword typed in textbox , I have to filter the user details.
I have written a stored procedure with prepared statement. But its not working.
SQL
create procedure prcUsers
(
	PvchFieldName varchar(30),
	PvchFieldValue varchar(30)
)
begin
	declare f,v varchar(30);
    set @fname=PvchFieldName;
	set @val=PvchFieldValue;
	set @q= concat('select * from tbmstuser where ',f,'=? like',v,'=?%');
	prepare stmt from @q;	
	execute stmt using @fname, @val;
	deallocate prepare stmt;
end


calling the procedure gives me the following error

SQL
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1	0.000 sec

Have to call like this
SQL
call prcUsers('vchFirstName','a');
Posted
Updated 16-Jan-13 20:43pm
v2
Comments
Sandeep Mewara 17-Jan-13 1:44am    
How do you call this SP?
Member 9762654 17-Jan-13 2:03am    
have given in my solution check with that

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