思迅软件PDA 3900 BUG 代码:05FF 子查询返回的值不止一个。当子查询跟随在 之后,或子查询用作表达式时

思迅软件PDA 3900 BUG 代码:05FF 子查询返回的值不止一个。当子查询跟随在 之后,或子查询用作表达式时_第1张图片


主程序:思迅商锐9.5

PDA 3900 服务端版本 1.1

事件类型:PDA查询报表 查询商品档案时 返回上图错误 

代码:05FF 子查询返回的值不止一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时
经过跟踪分析,发现是由于PDA服务程序代码,有一个BUG
	
	if @item_no='' or  @item_no is  null
	 begin
	  SELECT @as_searchstr  AS item_no, '查询不到商品信息,请重新输入!' AS item_name,@branchNo as branch_no, '' AS item_size, '' AS unit_no,  0.0  as stock_qty
	 end
	else
		SELECT a.item_no,
			   a.item_name,
			   '['+c.branch_no+']'+c.branch_name  as  branch_no,
			   isnull(a.item_size,'') as item_size,
			   isnull(a.unit_no,'')   as unit_no,
			   isnull((select t_im_branch_stock.stock_qty from t_im_branch_stock where t_im_branch_stock.item_no= a.item_no),0)  as stock_qty
		  FROM  t_bd_item_info a     --t_im_branch_stock b
			--inner  join t_bd_item_info a on  a.item_no = b.item_no
			inner  join t_bd_branch_info c on c.branch_no like @branchNo+'%'
		WHERE a.status <> '5' and c .branch_no like  @branchNo+'%'
		  and (a.item_no =@item_no)	 --
end
上述错误代码, 会筛选出大于1的多行记录。故导致整个过程错误。
 isnull((select t_im_branch_stock.stock_qty from t_im_branch_stock where t_im_branch_stock.item_no= a.item_no),0)  as stock_qty

解决方法

isnull((select t_im_branch_stock.stock_qty from t_im_branch_stock where t_im_branch_stock.item_no= a.item_no and branch_no like @branchNo ),0)  as stock_qty


你可能感兴趣的:(SQL,server修复,SQL,server语法,思迅软件,速达软件,博优软件,赢通软件,晋业软件,用友软件,金蝶软件,超赢软件,泰格软件,百威软件,方像软件,海信软件)