Reading OUT param in stored procedure

Reply

Join Date: Apr 2008
Posts: 497
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro in Training

Reading OUT param in stored procedure

 
0
  #1
Aug 29th, 2008
Hi,

Stored proc code below works fine in MySQL command prompt. It returns John because it is in table. However, i can't return or read the Out parametter in PHP. I mean i cant retrieve John. I did ask this in PHP forum but no answer.

  1. CREATE PROCEDURE `findname`(IN name_in VARCHAR(15), OUT name_out VARCHAR(15))
  2. BEGIN
  3. SELECT name INTO name_out FROM table WHERE name=name_in;
  4. END;
  5.  
  6. CALL findname('John', @out);
  7. SELECT @out;

  1. $query = "CALL findname('John', @err);";
  2. $run = mysql_query("SELECT @err");

What do i write to check if result is returns John or not?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 79
Reputation: varmadba is an unknown quantity at this point 
Solved Threads: 8
varmadba varmadba is offline Offline
Junior Poster in Training

Re: Reading OUT param in stored procedure

 
0
  #2
Sep 4th, 2008
Why cant you run a single query

  1. SELECT name FROM table WHERE name=name_in;

Some thing like this....

$sql = "SELECT name FROM table WHERE nam='$name_out'";
$result = mysql_query($sql, $db);
$row = mysql_fetch_row($result);
$name_from_db=$row[0];

if($name_out = $$name_from_db)
{
echo "It's John";
exit;
}

I am not expert in Php though
Last edited by varmadba; Sep 4th, 2008 at 10:11 am.
:- Varma

We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 497
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro in Training

Re: Reading OUT param in stored procedure

 
0
  #3
Sep 4th, 2008
Because, i want to learn how to read OUT parameter.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 79
Reputation: varmadba is an unknown quantity at this point 
Solved Threads: 8
varmadba varmadba is offline Offline
Junior Poster in Training

Re: Reading OUT param in stored procedure

 
0
  #4
Sep 4th, 2008
Just My taught

@out variable means you are creating a temporary variable
Temporary variables are connection specific

make sure these both are executed on one connection

  1. $query = "CALL findname('John', @err);";
  2. $run = mysql_query("SELECT @err");
:- Varma

We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the MySQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC