Error: Streaming not supported over multiple column result
We got this error after creating a stored proc similar to one we had working earlier:
Event ID: 5740
Description:
The adapter "SQL" raised an error message. Details "
I do have two SQL statements in my stored proc, but here's why. I want to test to see if there are any rows to be "picked", then if so, I want to store a row in a "Batch" table and then assign the resulting BatchID (identity column) to all the rows I pick. I've done this in a similar stored proc that worked okay. The one below did not work. I suspect two differences: 1) the one below uses a view and joins several tables together (whereas the other is a simple single table), and 2) the one below uses an extra parm and in the where clause.
BEFORE (Causes above Error)
ALTER PROCEDURE spBTSpollsTransactionBatch
@TaskName varchar(50)
AS
DECLARE @now DATETIME
SET @now = GETDATE()
select * from vw_BTSpollsTransactionBatch
where Status = '1' and TaskName = @TaskName
--do not attempt to insert OA_Status_Batch unless there are some new rows to process
if @@RowCount >= 1
BEGIN
Begin Tran
INSERT INTO PA_Transaction_Batch (creationdate)
VALUES(getdate())
UPDATE vw_BTSpollsTransactionBatch
SET Status = '2' ,
EffectiveStart = @now,
TransactionBatchID = @@Identity -- identity key of row just inserted into OA_Status_Batch
WHERE TransactionID IN
(select top 10 transactionid from vw_BTSpollsTransactionBatch
where Status = '1' and TaskName = @TaskName)
Commit
END
-- put this select outside of the if statement above
SELECT * from vw_BTSpollsTransactionBatch where EffectiveStart = @now
FOR XML AUTO --, XMLDATA -- (using attributes instead of elements)
AFTER Corrects Above Error
The example below now sets a variable instead of returning a row set.
ALTER PROCEDURE spBTSpollsTransactionBatch
@TaskName varchar(50)
AS
DECLARE @now DATETIME
SET @now = GETDATE()
Declare @MyCount int
select top 1 @MyCount= count(TransactionID) from vw_BTSpollsTransactionBatch
where Status = '1' and TaskName = @TaskName
--do not attempt to insert OA_Status_Batch unless there are some new rows to process
if @@MyCount >= 1
BEGIN
Begin Tran
INSERT INTO PA_Transaction_Batch (creationdate)
VALUES(getdate())
UPDATE vw_BTSpollsTransactionBatch
SET Status = '2' ,
EffectiveStart = @now,
TransactionBatchID = @@Identity -- identity key of row just inserted into OA_Status_Batch
WHERE TransactionID IN
(select top 10 transactionid from vw_BTSpollsTransactionBatch
where Status = '1' and TaskName = @TaskName)
SELECT * from vw_BTSpollsTransactionBatch where EffectiveStart = @now
FOR XML AUTO --, XMLDATA -- (using attributes instead of elements)
Commit
END


<< Home