SQLite Forum

multiple queries
Login
<code>
public int RunOneStatement( SQLiteConnection db, string sqlGlom, out int charsUsed, ... )
{
  char * zSql = sqlGlom.?;
  rc = sqlite3_prepare_v2(db.?, zSql, sqlGlom.bytelength, & pStmt, & pzTail);
  step ...;
  finalize ...;
  charsUsed = 0;
  while (*zSql && zSql < pzTail){
    // Advance zSql by one utf-8 code.
    ++charsUsed;
  }
  // Free zSql if necessary.
}
</code>

The '...' in the signature would likely be a delegate to handle per-step actions that are needed.  The '.?' methods are whatever it takes to get representations usable in native (or C) code.

This would enable the same sort of loop, consuming a single SQL statement per iteration, that you envisioned when you asked about getting/using pzTail. The difference here is that pzTail is still a valid pointer where used. At the C# level calling the above function, just lop off as many character codes as charsUsed indicates, or terminate the loop when it equals zero.