Class: FireRuby::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/src.rb

Overview

This class represents a Firebird database transaction. There may be multiple transaction outstanding against a connection at any one time.

Constant Summary collapse

TPB_VERSION_1 =
1
TPB_VERSION_3 =
3
TPB_CONSISTENCY =
1
TPB_CONCURRENCY =
2
TPB_SHARED =
3
TPB_PROTECTED =
4
TPB_EXCLUSIVE =
5
TPB_WAIT =
6
TPB_NO_WAIT =
7
TPB_READ =
8
TPB_WRITE =
9
TPB_LOCK_READ =
10
TPB_LOCK_WRITE =
11
TPB_VERB_TIME =
12
TPB_COMMIT_TIME =
13
TPB_IGNORE_LIMBO =
14
TPB_READ_COMMITTED =
15
TPB_AUTO_COMMIT =
16
TPB_REC_VERSION =
17
TPB_NO_REC_VERSION =
18
TPB_RESTART_REQUESTS =
19
TPB_NO_AUTO_UNDO =

Transaction parameter buffer value constants.

20

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connections) ⇒ Transaction

This is the constructor for the Transaction class.

Parameters

connections

Either a single instance of the Connection class or an array of Connection instances to specify a multi-database transaction.

Exceptions

Exception

Generated whenever the method is passed an invalid parameter or a problem occurs creating the transaction.



403
404
# File 'lib/src.rb', line 403

def initialize(connections)
end

Class Method Details

.create(connections, parameters) ⇒ Object

This method allows for the creation of a Transaction object with non-standard settings.

Parameters

connections

Either a single Connection object or an array of Connection objects that the new Transaction will be associated with.

parameters

An array of the parameters to be used in creating the new constants. Populate this from the TPB constants defined within the class.

Exceptions

FireRubyError

Generated whenever a problem occurs creating the transaction.



503
504
# File 'lib/src.rb', line 503

def Transaction.create(connections, parameters)
end

Instance Method Details

#active?Boolean

This method is used to determine whether a Transaction object is still valid for use (i.e. commit or rollback has not been called for the Transaction).

Returns:

  • (Boolean)


412
413
# File 'lib/src.rb', line 412

def active?
end

#commitObject

This method commits the details outstanding against a Transaction object. The Transaction object may not be reused after a successful call to this method.

Exceptions

Exception

Generated whenever a problem occurs committing the details of the transaction.



445
446
# File 'lib/src.rb', line 445

def commit
end

#connectionsObject

This is the accessor for the connections attribute. This method returns an array of the connections that the transaction applies to.



420
421
# File 'lib/src.rb', line 420

def connections
end

#execute(sql) {|row| ... } ⇒ Object

This method executes a SQL statement using a Transaction object. This method will only work whenever a Transaction object applies to a single Connection as it would otherwise be impossible to determine which connection to execute against. If the statement executed was a SQL query then the method returns a ResultSet object. For non-query SQL statements (insert, update or delete) the method returns an Integer that contains the number of rows affected by the statement. For all other statements the method returns nil. The method also accepts a block that takes a single parameter. If the SQL statement was a query the block will be invoked and passed each row retrieved.

Parameters

sql

A string containing the SQL statement to be executed.

Exceptions

Exception

Generated whenever the Transaction object represents more than one connection or a problem occurs executing the SQL statement.

Yields:

  • (row)


482
483
484
# File 'lib/src.rb', line 482

def execute(sql)
   yield(row)
end

#for_connection?(connection) ⇒ Boolean

This method is used to determine whether a given Transaction applies to a specified Connection.

Parameters

connection

A reference to the Connection object to perform the test for.

Returns:

  • (Boolean)


432
433
# File 'lib/src.rb', line 432

def for_connection?(connection)
end

#rollbackObject

This method rolls back the details outstanding against a Transaction object. The Transaction object may not be reused after a successful call to this method.

Exceptions

Exception

Generated whenever a problem occurs rolling back the details of the transaction.



458
459
# File 'lib/src.rb', line 458

def rollback
end