| Author |
Topic |
|
Krisabi
Starting Member
2 Posts |
Posted - 2004-08-13 : 06:21:38
|
| I'm having problems with the stored procedure below because i'm not able to get the resultset or return the result of this procedure through or to vb (visual basic 6.0) and need help as to how to go about it.Thanks in advanceCREATE PROCEDURE sp_InterestByCertificateNo @CertificateNo varchar(15), @sDate smalldatetime, @eDate smalldatetimeAS DECLARE @IntDate smalldatetime, @FaceValue money, @Rate decimal, @Interest money, @Count int, @Amount money CREATE TABLE #InterestFlow ( InterestDate smalldatetime, FaceValue money, Rate decimal, Interest money, Balance money ) SET @Count = 0 DECLARE rsINT CURSOR FOR SELECT InterestDate,FaceValue,Rate,Interest FROM InterestAccruals WHERE certificateno=@CertificateNo AND InterestDate BETWEEN @sDate AND @eDate OPEN rsINT FETCH NEXT FROM rsINT INTO @IntDate, @Facevalue, @Rate, @Interest WHILE @@FETCH_STATUS = 0 BEGIN IF @Count = 0 BEGIN INSERT INTO #InterestFlow (InterestDate, FaceValue, Rate, Interest, Balance) VALUES(@IntDate, @FaceValue, @Rate,0 , @FaceValue) SET @Amount = @FaceValue + @Interest INSERT INTO #InterestFlow (InterestDate, FaceValue, Rate, Interest, Balance) VALUES(@IntDate, 0, 0, @Interest, @Amount) END ELSE BEGIN SET @Amount = @Amount + @Interest INSERT INTO #InterestFlow (InterestDate, FaceValue, Rate, Interest, Balance) VALUES(@IntDate, 0, 0, @Interest, @Amount) END SET @Count = @Count + 1 FETCH NEXT FROM rsINT INTO @IntDate, @Facevalue, @Rate, @Interest END CLOSE rsINT DEALLOCATE rsINT SELECT InterestDate, FaceValue, Rate, Interest, Balance FROM #InterestFlow |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2004-08-13 : 06:26:22
|
Try this -CREATE PROCEDURE sp_InterestByCertificateNo@CertificateNo varchar(15),@sDate smalldatetime,@eDate smalldatetimeASSET NOCOUNT ON DECLARE @IntDate smalldatetime,@FaceValue money,@Rate decimal,@Interest money,@Count int,@Amount moneyCREATE TABLE #InterestFlow(InterestDate smalldatetime,FaceValue money,Rate decimal,Interest money,Balance money) SET @Count = 0DECLARE rsINT CURSOR FORSELECT InterestDate,FaceValue,Rate,InterestFROM InterestAccruals WHERE certificateno=@CertificateNoAND InterestDate BETWEEN @sDate AND @eDateOPEN rsINTFETCH NEXT FROM rsINT INTO @IntDate, @Facevalue, @Rate, @InterestWHILE @@FETCH_STATUS = 0BEGINIF @Count = 0BEGIN INSERT INTO #InterestFlow(InterestDate, FaceValue, Rate, Interest, Balance)VALUES(@IntDate, @FaceValue, @Rate,0 , @FaceValue) SET @Amount = @FaceValue + @InterestINSERT INTO #InterestFlow(InterestDate, FaceValue, Rate, Interest, Balance)VALUES(@IntDate, 0, 0, @Interest, @Amount) ENDELSEBEGINSET @Amount = @Amount + @InterestINSERT INTO #InterestFlow(InterestDate, FaceValue, Rate, Interest, Balance)VALUES(@IntDate, 0, 0, @Interest, @Amount) ENDSET @Count = @Count + 1FETCH NEXT FROM rsINT INTO @IntDate, @Facevalue, @Rate, @InterestENDCLOSE rsINT DEALLOCATE rsINTSET NOCOUNT OFFSELECT InterestDate, FaceValue, Rate, Interest, Balance FROM #InterestFlow And if it works, consider making SET NOCOUNT ON part of your policy for stored procedures.-------Moo. :) |
 |
|
|
|
|
|