Method: SQLite::API.compile
- Defined in:
- ext/sqlite-api.c
.compile(db, sql) ⇒ Array
Compiles the given SQL statement and returns a new virtual machine handle for executing it. Returns a tuple: [ vm, remainder ], where remainder is any text that follows the first complete SQL statement in the sql parameter.
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'ext/sqlite-api.c', line 318 static VALUE static_api_compile( VALUE module, VALUE db, VALUE sql ) { sqlite *handle; sqlite_vm *vm; char *errmsg; const char *sql_tail; int result; VALUE tuple; GetDB( handle, db ); Check_Type( sql, T_STRING ); result = sqlite_compile( handle, STR2CSTR( sql ), &sql_tail, &vm, &errmsg ); if( result != SQLITE_OK ) { static_raise_db_error2( result, &errmsg ); /* "raise" does not return */ } tuple = rb_ary_new(); rb_ary_push( tuple, Data_Wrap_Struct( rb_cData, NULL, static_free_vm, vm ) ); rb_ary_push( tuple, rb_str_new2( sql_tail ) ); return tuple; } |