Is there any way when processing a SQL statement (SELECT, INSERT, UPDATE, DELETE) to retrieve the results of @@ROWCOUNT to establish how many rows were affected by the statement?
#SQL
#COBOLSQLCOBSQL
#COBOL
Is there any way when processing a SQL statement (SELECT, INSERT, UPDATE, DELETE) to retrieve the results of @@ROWCOUNT to establish how many rows were affected by the statement?
Is there any way when processing a SQL statement (SELECT, INSERT, UPDATE, DELETE) to retrieve the results of @@ROWCOUNT to establish how many rows were affected by the statement?
The following code works for me:
exec sql delete Identity_Nummer
where Nummer = 0
end-exec
declare rowCount as binary-long.
exec sql select @@rowcount
into :rowCount
end-exec.
Is there any way when processing a SQL statement (SELECT, INSERT, UPDATE, DELETE) to retrieve the results of @@ROWCOUNT to establish how many rows were affected by the statement?
Thanks for your response.
Your code does work however in an OLTP type environment there is a reasonable chance that @@ROWCOUNT will have been reset by another interaction that has occurred between the time of the deletion and you submitting the query to retrieve it.
Is there any way when processing a SQL statement (SELECT, INSERT, UPDATE, DELETE) to retrieve the results of @@ROWCOUNT to establish how many rows were affected by the statement?
I believe that SQL Server maintains a separate @@ROWCOUNT for each Connection/transaction. I checked this with 2 SQL queries.
Is there any way when processing a SQL statement (SELECT, INSERT, UPDATE, DELETE) to retrieve the results of @@ROWCOUNT to establish how many rows were affected by the statement?
Thanks for your response I will give this a try and see whether it all works.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.