sql server - Function has too many arguments specified in Sql query -
sql server - Function has too many arguments specified in Sql query -
in below code have function , query function homecoming batchrelease quantity.i have include function in select sqlquery throws error"procedure or function dbo.getbatchreleasequantity has many arguments specified.".please help me overcome issue.
select p.productid, p.productname, isnull((select isnull( currentstock,0.00) productstatus ps ps.productid =p.productid , ps.locationid = 1 , ps.statusdatetime= '2014-08-27' , ps.productid=p.productid),0) openingstockquantity, isnull((select isnull( (currentstock*ps.unitprice),0.00) productstatus ps ps.productid =p.productid , ps.locationid = 1 , ps.statusdatetime= '2014-08-27' , ps.productid=p.productid),0) openingstockvalue, isnull((select isnull( currentstock,0.00) productstatus ps ps.productid =p.productid , ps.locationid = 1 , ps.statusdatetime= '2014-08-27' , ps.productid=p.productid),0) closingstockquantity, isnull((select isnull( (currentstock*ps.unitprice),0.00) productstatus ps ps.productid =p.productid , ps.locationid = 1 , ps.statusdatetime= '2014-08-27' , ps.productid=p.productid),0) closingstockvalue, (select dbo.getbatchreleasequantity(1,2, '2014-01-27 00:00:00', '2014-11-27 23:59:59') batchreleasequantity productstatus ps ps.locationid = 1 , ps.productid=p.productid , ps.statusdatetime > = '2014-01-27 00:00:00' , ps.statusdatetime <= '2014-10-27 23:59:59' ) -- isnull((select isnull( (dbo.getbatchreleasequantity(1,2, '2014-01-27 00:00:00', '2014-11-27 23:59:59')),0.00) --from productstatus ps --where ps.productid =p.productid -- , ps.locationid = 1 -- , ps.statusdatetime= '2014-08-27' -- , ps.productid=p.productid),0) batchout product p --- select dbo.getbatchreleasequantity(@i_locationid,p.productid,@i_date,@i_date) product p left outer bring together locationproductmap lmp on lmp.productid=p.productid lmp.productinflow=1
function
alter function [dbo].[getbatchreleasequantity] () returns int --with encryption begin declare @i_locationid varchar(50) declare @i_productid int declare @i_startdate varchar(50) declare @i_enddate varchar(50) homecoming (select sum( batchreleasequantity) batchreleasequantity batchreleasedetails brd left outer bring together batchrelease br on br.batchreleaseid=brd.batchreleaseid productid=@i_productid , locationid=@i_locationid , brd.createdon>=@i_startdate , brd.createdon<=@i_enddate)
your function doesn't have parameters, need set them in ()
, example:
create function add together ( @p1 int, @p2 int ) returns int begin retutn @p1 + @p2 end
so alter yours moving variables parameters instead:
alter function [dbo].[getbatchreleasequantity] ( @i_locationid varchar(50), @i_productid int, @i_startdate varchar(50), @i_enddate varchar(50) ) returns int --with encryption begin homecoming (select sum( batchreleasequantity) batchreleasequantity batchreleasedetails brd left outer bring together batchrelease br on br.batchreleaseid=brd.batchreleaseid productid=@i_productid , locationid=@i_locationid , brd.createdon>=@i_startdate , brd.createdon<=@i_enddate) end
also need think how calling appear passing in int
first parameter in function it's declared varchar(50)
. may need @i_locationid
parameter should int
.
sql sql-server
Comments
Post a Comment