If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Does a procedure return a boolean value?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-06-10, 11:24
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 791
Does a procedure return a boolean value?

I have this very simple proc that I believe is causing me grief by returning a true value but I'm not really sure. This is the only proc that I have that is doing this and it is making my app fail.

Do procs normally send out boolean values? Does anyone see an issue with this the way it sits? Here is the proc:

Code:
DELIMITER '//'
CREATE PROCEDURE phoneIsRegistered
(
    IN  iPhone bigint(10)
  , OUT oPhone bigint(10)
)
BEGIN
  SELECT
    phone
  FROM
      user
  WHERE
      phone = iPhone
  INTO
      oPhone;
END //
DELIMITER ';'
Reply With Quote
  #2 (permalink)  
Old 01-06-10, 12:01
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
frank, i must preface this by saying that i have yet to write my first mysql stored procedure

still, something puzzles me about yours

first, what do you ~want~ the procedure to return? TRUE/FALSE or ophone/NULL? does the name of the proc adequately reflect this? and if you actually want it to ~return~ something, shouldn't it be a FUNCTION rather than a PROCEDURE?

second, what happens if two users have the same phone?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-06-10, 13:27
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 791
Quote:
Originally Posted by r937 View Post
frank, i must preface this by saying that i have yet to write my first mysql stored procedure

still, something puzzles me about yours

first, what do you ~want~ the procedure to return? TRUE/FALSE or ophone/NULL? does the name of the proc adequately reflect this? and if you actually want it to ~return~ something, shouldn't it be a FUNCTION rather than a PROCEDURE?

second, what happens if two users have the same phone?
Heya Rudy. Thanks for the help and the time.

What I'm looking for this proc to return is the exact same phone number that is fed into it. (oPhone) In other words, I'd send in a phone number and test against the value of count(phone). If I have a single row returned, I know that the phone number already exists and I can continue on with my processing from there.

I've had to upgrade this database class because the one I was using would not work with procs. This is nothing short of a nightmare though. Since I last posted, I've come to find that PHP seriously lacks support for procedures and there are major hacks involved in getting this to work properly.

The short answer is that my proc is in fact working as expected but PHP can't handle them; gracefully anyway.

As far as the phone number is concerned, it is the PK so there can never be more than one. (A wise man once taught me about PKs)

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On