SQCloudVMBindParameterIndex

int SQCloudVMBindParameterIndex (SQCloudVM *vm, const char *name);

Description

Return the index of an SQL parameter given its name. The index value returned is suitable for use as the second parameter to SQCloudVMBind. A zero is returned if no matching parameter is found.

This function resembles the bind_parameter_index SQLite API.

Parameters

Return value

An int representing the index of the name parameter.

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 ('?param1');", -1, NULL);

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

    // get the parameter index
    int index = SQCloudVMBindParameterIndex(vm, "param1");
}