首页 > 后端开发 > php教程 > php 执行存储过程返回值得有关问题?

php 执行存储过程返回值得有关问题?

WBOY
发布: 2016-06-13 12:05:24
原创
841 人浏览过

php 执行存储过程返回值得问题???
我的mysql存储过程代码如下
怎么样在php中执行时得到对应的返回值???

declare vCNC_ID int;<br />  set vCnt=0;<br />  SELECT count(trlm.TRAVELER_ID) into vCnt from tr_traveler_lot_master trlm<br />   WHERE trlm.ORGANIZATION_ID=pOrg_ID AND trlm.SITE_ID=pSite_id<br />     AND trlm.TRAVELER_CODE=pTraveler_code;<br />  IF ISNULL(vCnt)=0 and vCnt>0 THEN<br />     SELECT trlm.TRAVELER_ID into vTraveler_id from tr_traveler_lot_master trlm<br />      WHERE trlm.ORGANIZATION_ID=pOrg_ID AND trlm.SITE_ID=pSite_id<br />        AND trlm.TRAVELER_CODE=pTraveler_code;<br />  ELSE<br />      SELECT '错误的托盘ID.....!';<br />      -- SELECT 'No Traveler ID issued.....!';<br />      LEAVE proc_main;<br />  END IF;<br />  set vCnt=0;<br />  SELECT count(trll.TRAVELER_ID) into vCnt from tr_traveler_lot_logging trll<br />   WHERE trll.ORGANIZATION_ID=pOrg_ID AND trll.SITE_ID=pSite_id<br />     AND trll.TRAVELER_ID=vTraveler_id and TRANSACTION_CODE<9;<br />  IF ISNULL(vCnt)=0 and vCnt>0 THEN<br />     SELECT '托盘ID已经开始.....!';<br />     -- SELECT 'Traveler ID had been started.....!';<br />     LEAVE proc_main;<br />  ELSE<br />     SELECT CNC_ID into vCNC_ID FROM tr_cnc_master tcm where tcm.ORGANIZATION_ID=pOrg_id and tcm.CNC_CODE= pCNC_CODE;<br />  END IF;  -- Second Count<br />--  Check CNC is in running by other Tray<br />  set vCnt=0;<br />  SELECT count(trll.TRAVELER_ID) into vCnt from tr_traveler_lot_logging trll<br />   WHERE trll.ORGANIZATION_ID=pOrg_ID AND trll.SITE_ID=pSite_id<br />     AND trll.CNC_ID=vCNC_ID and TRANSACTION_CODE<9;<br />  IF ISNULL(vCnt)=0 and vCnt>0 THEN<br />     SELECT 'ABCID已经开始被其他托盘使用.....!';<br />     -- SELECT 'CNC ID had been started by other tray.....!';<br />     LEAVE proc_main;<br />  END IF;  --  Check CNC is in running by other Tray<br />  -- Check CNC load Program or not<br />  set vCnt=0;<br />  SELECT count(tch.CNC_ID) into vCnt from  tr_cnc_header tch<br />   WHERE tch.ORGANIZATION_ID=pOrg_ID AND tch.CNC_ID=vCNC_ID;<br />  IF ISNULL(vCnt)=0 and vCnt>0 THEN<br />     SELECT CNC_ID into vCNC_ID FROM tr_cnc_master tcm where tcm.ORGANIZATION_ID=pOrg_id and tcm.CNC_CODE= pCNC_CODE;<br />     call Traveler_LogCreation (pOrg_id,vTraveler_id,pSite_ID,1,sysdate(),vCNC_id,pUser);<br />  ELSE<br />     SELECT '无 ABC 程序配置.....!';<br />     -- SELECT 'No CNC program loaded.....!';<br />     LEAVE proc_main;<br />  END IF;  -- Third Count     <br />  SELECT 'Ok';<br />end proc_main
登录后复制

------解决方案--------------------
你这个存储过程会返回多个结果集吧?看不大清楚
如果是,那么请用 mysqli 扩展或 PDO 类,mysql 扩展只能接受一个结果集
读取时需分别用
mysqli_next_result
PDOStatement::nextRowset 
移动结果集指针
注意:只要结果集没有读空。就不能重新查询

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板