Re: [sqlite] changing compiled SQL statement
On Tue, Sep 13, 2011 at 4:36 AM, Baruch Bursteinwrote: > If I compile a SQL statement, can I immediately change that sql string? > e.g., Is this allowed: > > sql = sqlite3_mprintf("select a from b where c = %Q;", d); > sqlite3_prepare_v2(db, sql, -1, , 0); > sqlite3_step(stmt); > strcpy(a, (char *)sqlite3_column_text(stmt, 0)); > sqlite3_free(sql); // or sql = "blah blah"; > Yes. sqlite3_prepare_v2() makes it's own copy of the original SQL. > . > . > . > sqlite3_step(stmt); > strcpy(a, (char *)sqlite3_column_text(stmt, 0)); > . > . > . > sqlite3_finalize(stmt); > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] changing compiled SQL statement
If I compile a SQL statement, can I immediately change that sql string? e.g., Is this allowed: sql = sqlite3_mprintf("select a from b where c = %Q;", d); sqlite3_prepare_v2(db, sql, -1, , 0); sqlite3_step(stmt); strcpy(a, (char *)sqlite3_column_text(stmt, 0)); sqlite3_free(sql); // or sql = "blah blah"; . . . sqlite3_step(stmt); strcpy(a, (char *)sqlite3_column_text(stmt, 0)); . . . sqlite3_finalize(stmt); ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] changing compiled SQL statement
If I compile a SQL statement, can I immediately change that sql string? e.g., Is this allowed: sql = sqlite3_mprintf("select a from b where c = %Q;", d); sqlite3_prepare_v2(db, sql, -1, , 0); sqlite3_step(stmt); strcpy(a, (char *)sqlite3_column_text(stmt, 0)); sqlite3_free(sql); // or sql = "blah blah"; . . . sqlite3_step(stmt); strcpy(a, (char *)sqlite3_column_text(stmt, 0)); . . . sqlite3_finalize(stmt); ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users