Vely logo Empower C
install     tutorials     examples     documentation     license     about

11.0.11 released on Jul 25, 2022



Get number of rows affected by query.


affected-rows#<query name> [ to [ define ] <variable> ]


Use affected-rows to get the number of rows affected by a query <query name> executed by run-query/start-query. Without "to" clause, this number is printed out. If "to" clause is used, then the number is stored to <variable>, which you can create if "define" is used.

affected-rows can be used anywhere after the query executed.

The number of rows affected is typically used for DML operations such as INSERT, UPDATE or DELETE. For SELECT, it may be the same as row-count which returns the number of rows from a query. See your database documentation for more.


Get the number of affected rows:
define-query#my_query="insert into employee (firstName, lastName) values ('sergio', 'fernandez'), ('jerry', 'lopez')"
// Define variable 
affected-rows#my_query to define aff_rows

if (aff_count!=2) {
   @<div>Number of rows affected is not 2, but rather it is <<pf-out "%lld", aff_count>></div>

To use an existing integer variable:
num aff_count;
affected-rows#my_query to aff_count


Database ( on-error   affected-rows   error-text   error   begin-transaction   column-count   column-data   database_queries   column-names   commit-transaction   prepared_statements   current-row   database_config_file   define-query   exec-query   loop-query   query-result   rollback-transaction   row-count   run-query   start-query  )  SEE ALL (documentation)

Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. This web page is licensed under CC-BY-SA-4.0.