Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803

    Unanswered: 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 ';'

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    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)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •