The Little Guy Posted October 15, 2008 Share Posted October 15, 2008 How come this SQL query works in MySQL Administrator, but doesn't work in a web browser, or PHP MyAdmin? call GetNearbyZipCodes('55068', '10') Error Message: PROCEDURE murdercup.GetNearbyZipCodes can't return a result set in the given context Quote Link to comment https://forums.phpfreaks.com/topic/128608-solved-stored-procedure/ Share on other sites More sharing options...
The Little Guy Posted October 16, 2008 Author Share Posted October 16, 2008 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/128608-solved-stored-procedure/#findComment-667516 Share on other sites More sharing options...
DarkWater Posted October 16, 2008 Share Posted October 16, 2008 We'd need to see the procedure. Quote Link to comment https://forums.phpfreaks.com/topic/128608-solved-stored-procedure/#findComment-667520 Share on other sites More sharing options...
The Little Guy Posted October 17, 2008 Author Share Posted October 17, 2008 The Procedure: CREATE DEFINER=`murdercup`@`%` PROCEDURE `GetNearbyZipCodes`( zipbase varchar (6), `range` numeric (15) ) BEGIN DECLARE lat1 decimal (5,2); DECLARE long1 decimal (5,2); DECLARE rangeFactor decimal (7,6); SET rangeFactor = 0.014457; SELECT `lat`,`log` into lat1,long1 FROM zipCodes WHERE zip = zipbase; SELECT B.zip FROM zipCodes AS B WHERE B.`lat` BETWEEN lat1-(`range`*rangeFactor) AND lat1+(`range`*rangeFactor) AND B.`log` BETWEEN long1-(`range`*rangeFactor) AND long1+(`range`*rangeFactor) AND GetDistance(lat1,long1,B.`lat`,B.`log`) <= `range`; END The function: CREATE DEFINER=`murdercup`@`%` FUNCTION `GetDistance`(lat1 numeric (9,6), lon1 numeric (9,6), lat2 numeric (9,6), lon2 numeric (9,6) ) RETURNS decimal(10,5) BEGIN DECLARE x decimal (20,10); DECLARE pi decimal (21,20); SET pi = 3.14159265358979323846; SET x = sin( lat1 * pi/180 ) * sin( lat2 * pi/180 ) + cos( lat1 *pi/180 ) * cos( lat2 * pi/180 ) * cos( (lon2 * pi/180) - (lon1 *pi/180) ); SET x = atan( ( sqrt( 1- power( x, 2 ) ) ) / x ); RETURN ( 1.852 * 60.0 * ((x/pi)*180) ) / 1.609344; END Quote Link to comment https://forums.phpfreaks.com/topic/128608-solved-stored-procedure/#findComment-667855 Share on other sites More sharing options...
The Little Guy Posted October 17, 2008 Author Share Posted October 17, 2008 Anyone know why? Quote Link to comment https://forums.phpfreaks.com/topic/128608-solved-stored-procedure/#findComment-668061 Share on other sites More sharing options...
fenway Posted October 17, 2008 Share Posted October 17, 2008 Did you try using mysqli_multi_query()? I'd read this PHP bug report too. Quote Link to comment https://forums.phpfreaks.com/topic/128608-solved-stored-procedure/#findComment-668123 Share on other sites More sharing options...
The Little Guy Posted October 17, 2008 Author Share Posted October 17, 2008 Hmm... wonder why this flag isn't supported: CLIENT_MULTI_RESULTS Quote Link to comment https://forums.phpfreaks.com/topic/128608-solved-stored-procedure/#findComment-668212 Share on other sites More sharing options...
The Little Guy Posted October 17, 2008 Author Share Posted October 17, 2008 but cool that works. Quote Link to comment https://forums.phpfreaks.com/topic/128608-solved-stored-procedure/#findComment-668281 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.