Variables in MySQL stored procedures use Select…Into … to obtain values that encounter null. Help!

  node.js, question

Help me to see what’s wrong, thank you very much.
Make sure the database inside has records.
There is nothing wrong with program code, parameter assignment and sequence.

var productCategoryID = helper.emptyUuid;
 var parentID = req.body.parentID ?   req.body.parentID : helper.emptyUuid;
 var usePorc = "CALL usp_productCategory_create(?  ,?  ,?  ,?  ,?  ,@returnCode);"  ;
 var useParams = [productCategoryID, req.body.name, req.body.details, parentID, req.session.adminid];

Stored procedure, error.

CREATE DEFINER=`root`@`localhost` PROCEDURE `usp_productCategory_create`(
 in param_porductcategoryid char(50)
 ,in param_name varchar(20)
 ,in param_details varchar(200)
 ,in param_parentID char(50)
 ,in param_userID char(50)
 ,out returnCode char(12))
 BEGIN
 DECLARE var_exists int;
 SET returnCode='003001000';
 SELECT count(productCategoryID) into var_exists FROM productcategories WHERE productCategoryID=param_parentID group by productCategoryID;
 IF var_exists=1 then
 SET returnCode='003001001';
 end if;
 set returnCode=CAST(var_exists AS char(12));  //The statement added later was used for testing and the result was Null
 select returnCode;
 END

Oh … at first sight in the morning … my variable name was wrongly defined …


Resolved.
Previously, sublimeText was used to edit the saved code, ctrl+alt+F Format the code, and value was automatically added with several spaces. ParentID was originally uuid, with spaces added, the length changed to 82. Sweat.
Furthermore, it was previously implemented under mssql and passed directly. Now MySQL is changed. Parentid is passed to stored procedure inside and returned as’ 00000000-0000-0000-0000-0000000000000 \ r \ n’

<select name="parentID" class="form-control">
 < percentage categories [0]. foreach (function) {percentage >
 < percentage if (category.productcategoryid = = parentid) {percentage >
 < option value= "< percentage = category.productCategoryID percentage >
 " selected>
 < percent} else {percent >
 < option value= "< percentage = category.productCategoryID percentage >
 ">
 < percentage} percentage >
 </select>