SQCloudVMTotalChanges

int64_t SQCloudVMTotalChanges (SQCloudVM *vm);

Description

Thi function returns the total number of rows inserted, modified or deleted by all INSERT, UPDATE or DELETE statements completed since the database connection was opened, including those executed as part of trigger programs. Executing any other type of SQL statement does not affect the value returned by SQCloudVMTotalChanges. Changes made as part of foreign key actions are included in the count, but those made as part of REPLACE constraint resolution are not. Changes to a view that are intercepted by INSTEAD OF triggers are not counted.

Count total changes without a VM

If you need to get the total changes from a SQCloudConnection object you can send a DATABASE GET TOTAL CHANGES command.

Parameters

Return value

An int64_t with the number of total changes.

Example

int main (int argc, const char * argv[]) {
    // setup config
    SQCloudConfig config = {0};
    config.username = "myusername";
    config.password = "mypassword"

    SQCloudConnection *conn = SQCloudConnect("myproject.sqlite.cloud", SQCLOUD_DEFAULT_PORT, &config);
    if (SQCloudIsError(conn)) {
        printf("ERROR connecting: %s (%d)\n", SQCloudErrorMsg(conn), SQCloudErrorCode(conn));
        return -1;
    } else {
        printf("Connection to host OK...\n\n");
    }

    // choose a database first
    SQCloudResult *r = SQCloudExec(conn, "USE DATABASE mydatabase.sqlite;");

    // compile the INSERT SQL statement
    SQCloudVM *vm = SQCloudVMCompile(conn, "INSERT INTO table1 (col1) VALUES ('Hello World');", -1, NULL);

    // execute the previously compiled statement
    SQCLOUD_RESULT_TYPE type = SQCloudVMStep(vm);

    // count total changes
    int64_t changes = SQCloudVMTotalChanges(vm);
}