Click here to Skip to main content
15,895,935 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i have create a store procedure in MySql and in that i m calling a parameter
which is in varchar and i want to convert it into integer

my store proceducre is

create procedure abc
(
search varchar(10)
)
begin
select id,name,city from table1
where id=cast(search as int);
end

but the cast function is giving error
and isnted of cast i have also used convert but it is also not working
convert(int,search);

pls help me ...

Thanks

Regards
Sagar Khairnar
Posted
Updated 23-Mar-10 21:50pm
v2

What error are you getting?


sagar55 wrote:
SQL
create procedure abc
(
search varchar(10)
)



I think it should be
SQL
@search varchar(10)


and
where id=cast(@search as int);
 
Share this answer
 
hi sir,

u have suggest the is in MsSql
but i want that in MySql

so can u give again suggest me that

regards
Sagar55
 
Share this answer
 
Common sense would suggest you pass an integer to your stored proc. This would also allow you to sanitise your input in the presentation layer, instead of having an error deep in your data layer.

Please don't push 'answer' to ask more questions, edit your post to add detail.
 
Share this answer
 

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