ROW_COUNT Function

Description

The ROW_COUNT function returns the number of rows updated (UPDATE, INSERT, DELETE) by the previous statement. Note that the ROW_COUNT function execution area at the SQL level is limited to the client session in which the SQL was created. If this function is called after executing SQL with the ;run or ;xrun command, it returns -1.

Syntax

ROW_COUNT()

Example

CREATE TABLE rc (i int);

INSERT INTO rc VALUES (1),(2),(3),(4),(5),(6),(7);

SELECT ROW_COUNT();

   row_count()

===============

              7

 

UPDATE rc SET i = 0 WHERE i >  3;

SELECT ROW_COUNT();

   row_count()

===============

              4

 

DELETE FROM rc WHERE i = 0;

SELECT ROW_COUNT();

   row_count()

===============

              4