chenhuajuan 2013-11-14 19:47
浏览 593
已采纳

请问在java 里调用存储过程,显示数据,当传的参数为NULL时,查询所有数据,这个怎处理呢?

请问在java 里调用存储过程,显示数据,当传的参数为NULL时,查询所有数据,这个怎处理呢?

create procedure ProcInventory
@GoodsCode nvarchar(50),
@GoodName nvarchar(50),
@BeginDate nvarchar(50),
@EndDate nvarchar(50)
as
declare @sql varchar(4000)

create table #test(ord varchar(30),GoodsCode nvarchar(20),GoodsName nvarchar(50),Amount nvarchar(50),UnitPrice nvarchar(50),
SumMoney nvarchar(10),Brand nvarchar(50),Unit nvarchar(50))
set @sql= 'insert into #Test(ord ,GoodsCode,GoodsName ,Amount ,UnitPrice ,
SumMoney ,Brand ,Unit )
select ROW_NUMBER() over(order by TbShGoods.GoodsCode) as ord, TbShGoods.GoodsCode,i.GoodName,(i.Amount-isnull(0,o.Amount)) as Amount,i.UnitPrice
,(i.Sum-isnull(0,o.Sum)) as Sum ,Brand,Unit
from tbshindetail i left join tbshoutdetail o on i.GoodsID=o.GoodsID
inner join TbShin on i.InID=TbShin.InID
inner join TbShGoods on i.GoodsID=TbShGoods.GoodsID
where i.GoodName='''+@GoodName+''' and TbShin.EnterDate between '''+@BeginDate+'''
and '''+@EndDate +''' and TbShGoods.GoodsCode='''+@GoodsCode+''''
print '11'

exec(@sql)
print @sql

  • 写回答

1条回答 默认 最新

      报告相同问题?

      悬赏问题

      • ¥30 VB6.0操作 webview2内核的浏览器如何精确实现网页弹窗处置
      • ¥15 pr导出的视频打不开,提示“缺少编解码器”怎么解决
      • ¥15 html里js获取php参数值不成功,帮改代码
      • ¥20 如何控制ant design的InputNumber组件 最多输入5位小数
      • ¥15 c语言学生基本信息管理系统
      • ¥100 火车头采集器采集求解
      • ¥88 关于#运行时间 时间重叠 和非重叠#的问题,如何解决?
      • ¥15 C语言,密切接触者追踪
      • ¥20 关于计算机网络问题,请附带讲解
      • ¥30 自动识别图像目标并判断