General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
The SP does give results but of the 10880 row returned isql/w
8156 row are the update result lines like
(1 row(s) affected)
And in vfp the result is +1 but no result set returned
if exists (select * from sysobjects where id = object_id('dbo.getled7') and sysstat & 0xf = 4)
drop procedure dbo.getled7
GO
CREATE PROCEDURE getled7
@ledcode varchar(10),
@fromdate datetime,
@TODATE DATETIME
AS
DECLARE @RUNBAL NUMERIC(18,2)
declare @curbal numeric(18,2)
DECLARE @OPENBAL NUMERIC(18,2)
CREATE TABLE #db_ledger (
glcd char (10) NULL,
gldt datetime NULL,
glfl char (8) NULL,
glblno char (10) NULL,
glblsrno char (5) NULL,
glamnt numeric(18, 2) NULL,
gltrcd char (10) NULL ,
matched numeric(18, 2) NULL,
balance numeric(18, 2) NULL,
glnarr varchar (255) NULL
)
SELECT @OPENBAL=SUM(GLAMNT) FROM GENLED WHERE GLCD = @LEDCODE AND GLDT < @FROMDATE GROUP BY GLCD
IF @@ROWCOUNT = 0
SELECT @OPENBAL = 0
insert into #db_ledger (glcd,gldt,glfl,glblno,glblsrno,glamnt,glnarr,BALANCE,MATCHED)
VALUES (@LEDCODE, @fromdate, "OPENING",'0','0',
@OPENBAL,"Opening Balance",0.00,0.00)
insert into #db_ledger
SELECT *
FROM GENLED
WHERE GLCD = @LEDCODE AND GLDT >=@FROMDATE AND GLDT <= @TODATE
ORDER BY GLDT
DECLARE LED_CURSOR CURSOR
FOR (select glamnt,balance from #db_ledger)
OPEN LED_CURSOR
FETCH NEXT FROM LED_CURSOR into @curbal,@OPENbal
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
SELECT @OPENBAL = @OPENBAL + @CURBAL
UPDATE #db_ledger SET balance = @OPENbal where current of led_cursor
END
FETCH NEXT FROM LED_CURSOR into @curbal,@runbal
END
close led_cursor
DEALLOCATE led_cursor
SELECT * FROM #db_ledger
GO
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only