VALUE executeStatementForExecuteBlock(VALUE statement) { VALUE result = Qnil; result = rb_execute_statement(statement); return(result); }
/** * This function is used to wrap the call to the executeOnConnection() function * made by the executeOnConnectionImmediate() function to help insure that the * transaction is rolled back in case of an error. * * @param array An array of the parameters for the function to use. * * @return The ResultSet object generated by execution or nil if it wasn't a * query. * */ VALUE executeBlock(VALUE array) { VALUE result = Qnil, connection = rb_ary_entry(array, 0), transaction = rb_ary_entry(array, 1), sql = rb_ary_entry(array, 2), statement = rb_ary_entry(array, 3); result = rb_execute_statement(statement); rb_statement_close(statement); return(result); }
static VALUE executeOnConnection(VALUE self, VALUE sql, VALUE transaction) { VALUE results = Qnil, statement = rb_statement_new(self, transaction, sql, INT2FIX(3)); results = rb_execute_statement(statement); if(results != Qnil && rb_obj_is_kind_of(results, rb_cInteger) == Qfalse) { if(rb_block_given_p()) { VALUE row = rb_funcall(results, rb_intern("fetch"), 0), last = Qnil; while(row != Qnil) { last = rb_yield(row); row = rb_funcall(results, rb_intern("fetch"), 0); } rb_funcall(results, rb_intern("close"), 0); results = last; } } rb_statement_close(statement); return(results); }