Icon ROWSAFFECTED

Returns the number of rows affected by the execution of a statement.

Syntax
ROWSAFFECTED(<StatementName>)

<StatementName> =

Previously-executed statement

Returns
INTEGER

Usage
The ROWSAFFECTED function returns the number of rows affected by a given statement.

Examples
-- This procedure updates all Customers
-- who have purchased a product last year and
-- flags them to receive a mailer

CREATE PROCEDURE UpdateMailer(OUT NumCustomers INTEGER)
BEGIN
   DECLARE UpdateStmt STATEMENT;

   EXECUTE IMMEDIATE 'UPDATE Customers SET Mailer = False';

   PREPARE UpdateStmt FROM 'UPDATE Customers SET Mailer = True ' +
      'WHERE EXTRACT(YEAR FROM LastPurchased) = ' +
      'EXTRACT(YEAR FROM CURRENT_DATE()) - 1';

   EXECUTE UpdateStmt;

   SET NumCustomers = ROWSAFFECTED(UpdateStmt);

   UNPREPARE UpdateStmt;   

END

SQL 2003 Standard Deviations
This function deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis function is an ElevateDB extension.
Image