FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


SELECT in Procedure Causes Error #1312 (ER_SP_BADSELECT)





mexiwithacan
Hello,

I'm trying to create a simple stored procedure as a test right now, and I cannot seem to get this stored procedure to work.

The code looks as follows:

Code:

DELIMITER //
DROP PROCEDURE IF EXISTS `select_hello` //
CREATE PROCEDURE `select_hello`()
BEGIN
SELECT "Hello, World!";
END //
DELIMITER ;


All it's supposed to do is to return a result set containing one column and one row with the value "Hello, World!" in the single cell.

Instead, I get the following error in my offline development environment when calling the procedure from the phpMyAdmin interface:

#1312 - PROCEDURE mydatabase.select_hello can't return a result set in the given context

When I try the same steps in my online Frihost database, no errors are reported but I am taken back to the localhost-scoped interface (i.e., the interface shown when no database is selected).

The error is documented very, very briefly in the MySQL online documentation at the following URL:

http://dev.mysql.com/doc/refman/5.1/en/create-procedure.html

However, all that is said is: "For statements that can be determined only at runtime to return a result set, a PROCEDURE %s can't return a result set in the given context error occurs (ER_SP_BADSELECT)." I found this to be completely unhelpful in guiding me to the proper way to avoid this error.

I would appreciate any help with getting this simple stored procedure to work.
mexiwithacan
Peter Brawley helped me out on the MySQL Forums here: http://forums.mysql.com/read.php?98,370074,370573#msg-370573

I tested this with the following code:

Code:
<?php
$mysql_server = 'myserver';
$mysql_username = 'myusername';
$mysql_password = 'mypassword';
$mysql_db = 'mydatabase';

$mysqli = new MySQLi($mysql_server, $mysql_username, $mysql_password, $mysql_db);

$result = $mysqli->query('CALL select_hello');

while($row = $result->fetch_row()) {
   echo $row[0] . '<br />';
}
?>


"Hello, World!" was displayed very clearly on the resulting page.

I really do need to stay up-to-date with these developments in technology.
Related topics
Help: SQL error after uploading new files(thread updated)
Email Error
HELP!!!! My computer keeps rebooting over and over again.
Forum error when posting
Error Posting...
Frihost Forum Error (30/08/2005)
Error on posting
error
PHP DB Error: syntax error
DO YOU CHEAT?
Error Killer
Typo3, low memory causes error
User get error when choosing avatar from gallery[phpbb]
MySQL - Session error?
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.