简体   繁体   中英

SSRS subscription with cursor

In my (ssrs) data-driven subscription I try to use cursor. The result that I need: number of letters should be equal to the lines the cursor returns. Example:

SET ANSI_WARNINGS ON 
DECLARE cur CURSOR FOR
SELECT * FROM #ForResult

OPEN cur
    WHILE 1 = 1
    BEGIN
        FETCH NEXT FROM cur INTO @ID, @CommittedBy, @FlightNumber, @Dep, @DateBeg, @Carrier, @Arr
        IF @@FETCH_STATUS <> 0 BREAK

        SELECT CONVERT(VARCHAR(10), @DateBeg, 104)      AS [DateBeg]
             , CONVERT(VARCHAR(10), @DateBeg, 104)      AS [DateEnd]
             , @Dep                                     AS [AP]
             , @FlightNumber                            AS [FlightNumber]
             , 'email@y.ru' AS [Recip]
             , 'Отчет ' 
             + @FlightNumber
             + ' от ' + CONVERT(VARCHAR(10), @DateBeg)
             + ' а/к ' + @Carrier
             + ' ' + @Dep + ' - ' + @Arr 
             + ' // ' + @CommittedBy                    AS [Subject]        
    END
CLOSE cur
DEALLOCATE cur
SET ANSI_WARNINGS OFF

SET ANSI_WARNINGS solved problem Cannot read the next data row for the dataset

But subscription return only first cursor-result. How can I return all rows in different letters?

Is this the only code you have, because in SSRS, the code works very different than TSQL. It should be case sensitive, parameters which are string may work differently. Make sure you have it in a SP with all ANSI settings properly defined and run them again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM