مرتضی حمزه ئی
شنبه 06 مهر 1387, 11:36 صبح
سلام دوستان عزیز
من داخل یک sp ابتدا دستور create table #temp (sanadno int ,sumprice bigint, sumkol bigint) رانوشتم وداخل sp رکوردهایی را از جای دیگه داخل این فایل موقت میریزم ولی موقعی که داخل vb این sp را صدا میزنم خطا میده ولی اگه خط اول مربوط به ایجاد جدول موقت را بردارم خطا نمیده جالبه در query analyzer اگه sp را صدا کنم مشکل نداره وجواب میده اگر لطف کنید مرا از برزخ نجات بدید ممنون میشم متن کامل sp بصورت زیر است
CREATE procedure spsanad1_fetch
@anbar int
as
declare @sumkol bigint
declare @sanadno int ,@sumprice bigint ,@descp nvarchar(30),@anbar1 int ,@period int
declare sumanbar_cursor cursor for
select * from vwacckalasanad where anbar=@anbar
union all
select * from vwaccbargsanad where anbar=@anbar and sanadnov>0
union all
select * from vwaccbargfrsanad where anbar=@anbar and sanadnov>0
union all
select * from vwacchavsanad where anbar=@anbar and sanadnov>0
union all
select * from vwaccresidsanad where anbar=@anbar and sanadnov>0
union all
select * from vwaccentgtosanad where anbard=@anbar and sanadnodv>0
union all
select * from vwaccentgfrsanad where anbarg=@anbar and sanadnogv>0
union all
select * from vwaccezafsanad where anbar=@anbar and sanadnov>0
order by period
open sumanbar_cursor
set @sumkol=0
fetch next from sumanbar_cursor
into @sanadno ,@sumprice ,@descp ,@anbar1 ,@period
while @@fetch_status=0
begin
if @period<5
begin
set @sumkol=@sumkol+@sumprice
end
else
set @sumkol=@sumkol-@sumprice
insert into #temp values(@descp,@sanadno,@sumprice,@sumkol)
fetch next from sumanbar_cursor
into @sanadno ,@sumprice ,@descp ,@anbar1 ,@period
end
select @sumkol
close sumanbar_cursor
deallocate sumanbar_cursor
-- select * from #temp
GO
من داخل یک sp ابتدا دستور create table #temp (sanadno int ,sumprice bigint, sumkol bigint) رانوشتم وداخل sp رکوردهایی را از جای دیگه داخل این فایل موقت میریزم ولی موقعی که داخل vb این sp را صدا میزنم خطا میده ولی اگه خط اول مربوط به ایجاد جدول موقت را بردارم خطا نمیده جالبه در query analyzer اگه sp را صدا کنم مشکل نداره وجواب میده اگر لطف کنید مرا از برزخ نجات بدید ممنون میشم متن کامل sp بصورت زیر است
CREATE procedure spsanad1_fetch
@anbar int
as
declare @sumkol bigint
declare @sanadno int ,@sumprice bigint ,@descp nvarchar(30),@anbar1 int ,@period int
declare sumanbar_cursor cursor for
select * from vwacckalasanad where anbar=@anbar
union all
select * from vwaccbargsanad where anbar=@anbar and sanadnov>0
union all
select * from vwaccbargfrsanad where anbar=@anbar and sanadnov>0
union all
select * from vwacchavsanad where anbar=@anbar and sanadnov>0
union all
select * from vwaccresidsanad where anbar=@anbar and sanadnov>0
union all
select * from vwaccentgtosanad where anbard=@anbar and sanadnodv>0
union all
select * from vwaccentgfrsanad where anbarg=@anbar and sanadnogv>0
union all
select * from vwaccezafsanad where anbar=@anbar and sanadnov>0
order by period
open sumanbar_cursor
set @sumkol=0
fetch next from sumanbar_cursor
into @sanadno ,@sumprice ,@descp ,@anbar1 ,@period
while @@fetch_status=0
begin
if @period<5
begin
set @sumkol=@sumkol+@sumprice
end
else
set @sumkol=@sumkol-@sumprice
insert into #temp values(@descp,@sanadno,@sumprice,@sumkol)
fetch next from sumanbar_cursor
into @sanadno ,@sumprice ,@descp ,@anbar1 ,@period
end
select @sumkol
close sumanbar_cursor
deallocate sumanbar_cursor
-- select * from #temp
GO