Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 9.5   10.0   10.1   10.2   10.3   10.4   10.5   11.0   11.1   11.2    Statistic    FMM    Blog  

SQL.RowsAffected

Queries the number of rows affected.

Component Version macOS Windows Linux Server iOS SDK
SQL 2.6 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "SQL.RowsAffected"; Command )   More

Parameters

Parameter Description Example
Command The command reference number gained with SQL.NewCommand. $Command

Result

Returns number of rows or error message.

Description

Queries the number of rows affected.
Returns the number of rows affected by the last insert/update/delete command execution.
This normally only works if enabled, so please call SQL.SetCommandOption function to enable it if needed.

You may need to define cursor to be scrollable or cached in order to get number of rows in a recordset (For SELECT).

Examples

Requests a scrollable record set:

MBS( "SQL.SetCommandOption"; $Command; "Scrollable"; "True" )

Query number of records found:

Set Variable [ $query ; Value: "SELECT ID, Name, ChangedTS FROM Trainings WHERE ChangedTS >=:1 " ]
Set Variable [ $command ; Value: MBS("SQL.NewCommand"; $connection; $query ) ]
Set Variable [ $r; Value: MBS("SQL.SetParamAsDateTime"; $command; 1; $search_date ) ]
Set Variable [ $r; Value: MBS("SQL.SetCommandOption"; $Command; "Scrollable"; "True" )
Set Variable [ $r ; Value: MBS("SQL.Execute"; $command ) ]
Set Variable [ $count ; MBS( "SQL.RowsAffected"; $Command ) ]
# read records
Set Variable [ $r ; Value: MBS("SQL.FreeCommand"; $command ) ]

See also

Example Databases

Created 18th August 2014, last changed 20th December 2019


SQL.Rollback - SQL.SQLite3.EnableLoadExtension

Feedback: Report problem or ask question.