Пример #1
0
/**
 * This function provides clean up for the execution of a block associated
 * with the execute method.
 *
 * @param  array        An array of the parameters for the function to use.
 * @param  error        A reference to details relating to the exception raised.
 *
 * @return  Would always returns nil except that it always raises an exception.
 *
 */
VALUE executeRescue(VALUE array, VALUE error) {
  VALUE transaction = rb_ary_entry(array, 1),
        statement   = rb_ary_entry(array, 3);

  rb_funcall(transaction, rb_intern("rollback"), 0);
  rb_statement_close(statement);
  rb_exc_raise(error);
  return(Qnil);
}
Пример #2
0
/**
 * 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);
}
Пример #3
0
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);

}
Пример #4
0
VALUE ensureStatementClosedForExecuteBlock(VALUE statement)
{
	rb_statement_close(statement);

	return Qnil;
}