Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

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

This function is free to use.

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


SQL.Rollback - SQL.SQLite3.EnableLoadExtension