Jump to content

Recommended Posts

Posted (edited)

Hello. For the first time I try to understand this topic, but there are questions.
I create a test procedure
DELIMITER //
DROP procedure IF EXISTS UserExist //
 
CREATE procedure UserExist (IN UserName VARCHAR(50), out RetMsg int)
 
  BEGIN
 
    SELECT id INTO RetMsg FROM Tab WHERE user = UserName;
 
  END;
//
DELIMITER ;
 
DELIMITER //
DROP procedure IF EXISTS SomeAuth //
CREATE PROCEDURE SomeAuth (UserName VarCHAR(50))
  BEGIN
    DECLARE pid int DEFAULT 0;
    DECLARE pMSG int DEFAULT 0;
    DECLARE pFile Mediumblob;
    DECLARE IsUser VARCHAR(20);
    set IsUser ='DefVal';
    call UserExist(UserName, @pMSG);
 
    if pMSG = 0 then
      set pid = 0;
        else
      set pid = 1;
    end iF;
  select @pid, @pMSG ;
  END //
 
DELIMITER ;
call SomeAuth('xxxxxxxxxxxxxxxxx'); 

In return i have:

@pid @pMSG

<null> 20

and so, I do not understand why

pid =<nul>?

why not 0 (as default value) or 1 (as if statement).

Edited by cmh

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...