Class: Rubyfb::Statement
- Inherits:
-
Object
- Object
- Rubyfb::Statement
- Defined in:
- lib/src.rb,
lib/statement.rb
Overview
This class represents a prepared SQL statement that may be executed more than once.
Defined Under Namespace
Classes: ColumnMetadata
Constant Summary collapse
- SELECT_STATEMENT =
A definition for a SQL statement type constant.
1
- INSERT_STATEMENT =
A definition for a SQL statement type constant.
2
- UPDATE_STATEMENT =
A definition for a SQL statement type constant.
3
- DELETE_STATEMENT =
A definition for a SQL statement type constant.
4
- DDL_STATEMENT =
A definition for a SQL statement type constant.
5
- GET_SEGMENT_STATEMENT =
A definition for a SQL statement type constant.
6
- PUT_SEGMENT_STATEMENT =
A definition for a SQL statement type constant.
7
- EXECUTE_PROCEDURE_STATEMENT =
A definition for a SQL statement type constant.
8
- START_TRANSACTION_STATEMENT =
A definition for a SQL statement type constant.
9
- COMMIT_STATEMENT =
A definition for a SQL statement type constant.
10
- ROLLBACK_STATEMENT =
A definition for a SQL statement type constant.
11
- SELECT_FOR_UPDATE_STATEMENT =
A definition for a SQL statement type constant.
12
- SET_GENERATOR_STATEMENT =
A definition for a SQL statement type constant.
13
- SAVE_POINT_STATEMENT =
A definition for a SQL statement type constant.
14
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#close ⇒ Object
This method releases the database resources associated with a Statement object and should be explicitly called when a Statement object is of no further use.
-
#connection ⇒ Object
This is the accessor for the connection attribute.
- #create_column_metadata ⇒ Object
- #create_result_set(transaction) ⇒ Object
-
#dialect ⇒ Object
This is the accessor for the dialect attribute.
-
#exec(parameters = nil, transaction = nil) {|row| ... } ⇒ Object
This method executes the SQL statement within a Statement object optionaly passing it a set of parameters.
-
#exec_and_close(parameters = nil, transaction = nil) {|row| ... } ⇒ Object
This method behaves exactly as the exec() method, except that the statement is also closed.
-
#initialize(connection, sql) ⇒ Statement
constructor
This is the constructor for the Statement class.
-
#parameter_count ⇒ Object
This method fetches a count of the number of dynamic parameters for a statement object (i.e. the number of parameters that must be provided with values before the SQL statement can be executed).
-
#plan ⇒ Object
This method returns the SQL execution plan for the statement.
-
#prepare(transaction = nil) ⇒ Object
This method prepares the SQL statement.
-
#prepared? ⇒ Boolean
This method is used to determine whether a Statement object is prepared.
-
#sql ⇒ Object
This is the accessor for the SQL statement attribute.
-
#type ⇒ Object
This method is used to determine the type of a SQL statement.
Constructor Details
#initialize(connection, sql) ⇒ Statement
This is the constructor for the Statement class.
Parameters
- connection
-
The Connection object that the SQL statement will be executed through.
- sql
-
The SQL statement to be prepared for execution.
581 582 |
# File 'lib/src.rb', line 581 def initialize(connection, sql) end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
3 4 5 |
# File 'lib/statement.rb', line 3 def @metadata end |
Instance Method Details
#close ⇒ Object
This method releases the database resources associated with a Statement object and should be explicitly called when a Statement object is of no further use.
Exceptions
- FireRubyError
-
Generated whenever a problem occurs closing the statement object.
713 714 |
# File 'lib/src.rb', line 713 def close end |
#connection ⇒ Object
This is the accessor for the connection attribute.
588 589 |
# File 'lib/src.rb', line 588 def connection end |
#create_column_metadata ⇒ Object
9 10 11 |
# File 'lib/statement.rb', line 9 def ColumnMetadata.new end |
#create_result_set(transaction) ⇒ Object
13 14 15 |
# File 'lib/statement.rb', line 13 def create_result_set(transaction) ResultSet.new(self, transaction) end |
#dialect ⇒ Object
This is the accessor for the dialect attribute.
602 603 |
# File 'lib/src.rb', line 602 def dialect end |
#exec(parameters = nil, transaction = nil) {|row| ... } ⇒ Object
This method executes the SQL statement within a Statement object optionaly passing it a set of parameters. Parameterized statements use question marks as place holders for values that may change between calls to execute the statement. This method returns a ResultSet object if the statement executed was a SQL query. If the statement was a non-query SQL statement (insert, update or delete) then the method returns a count of the number of rows affected. For all other types of statement the method returns nil. This method accepts a block taking a single parameter. If this block is provided and the statement is a query then the rows returned by the query will be passed, one at a time, to the block.
Parameters
- parameters
-
An array of the parameters (optional) for the statement. An effort will be made to convert the values passed in to the appropriate types but no guarantees are made (especially in the case of text fields, which will simply use to_s if the object passed is not a String).
- transaction
-
A reference to the transaction object (optional). If this parameter is nil - the statement is execute within its own (implicit) transaction. For statements that return result set objects - the implicit transaction is resolved when the result set object is closed, for the other kind of statements the implicit transaction is resolved immediately after the execution
Exception
- Exception
-
Generated whenever a problem occurs translating one of the input parameters or executing the SQL statement.
673 674 675 |
# File 'lib/src.rb', line 673 def exec(parameters=nil, transaction=nil) yield row end |
#exec_and_close(parameters = nil, transaction = nil) {|row| ... } ⇒ Object
This method behaves exactly as the exec() method, except that the statement is also closed. If no result set is generated the statement is closed immediately, otherwise the statement close() call thakes place when the resul tset close() is called.
Parameters
- parameters
-
An array of the parameters (optional) for the statement. An effort will be made to convert the values passed in to the appropriate types but no guarantees are made (especially in the case of text fields, which will simply use to_s if the object passed is not a String).
- transaction
-
A reference to the transaction object (optional). If this parameter is nil - the statement is execute within its own (implicit) transaction. For statements that return result set objects - the implicit transaction is resolved when the result set object is closed, for the other kind of statements the implicit transaction is resolved immediately after the execution
Exception
- Exception
-
Generated whenever a problem occurs translating one of the input parameters or executing the SQL statement.
700 701 702 |
# File 'lib/src.rb', line 700 def exec_and_close(parameters=nil, transaction=nil) yield row end |
#parameter_count ⇒ Object
This method fetches a count of the number of dynamic parameters for a statement object (i.e. the number of parameters that must be provided with values before the SQL statement can be executed).
619 620 |
# File 'lib/src.rb', line 619 def parameter_count end |
#plan ⇒ Object
This method returns the SQL execution plan for the statement
Exceptions
- FireRubyError
-
Generated whenever a problem occurs obtaining the plan
722 723 |
# File 'lib/src.rb', line 722 def plan end |
#prepare(transaction = nil) ⇒ Object
This method prepares the SQL statement
Parameters
- transaction
-
A reference to the transaction object (optional). If this parameter is nil - the statement is prepared within its own (implicit) transaction.
Exception
- Exception
-
Generated whenever a problem occurspreparing the SQL statement.
640 641 |
# File 'lib/src.rb', line 640 def prepare(transaction=nil) end |
#prepared? ⇒ Boolean
This method is used to determine whether a Statement object is prepared
626 627 |
# File 'lib/src.rb', line 626 def prepared? end |
#sql ⇒ Object
This is the accessor for the SQL statement attribute.
595 596 |
# File 'lib/src.rb', line 595 def sql end |
#type ⇒ Object
This method is used to determine the type of a SQL statement. The method will return one of the constant SQL types defined within the class.
610 611 |
# File 'lib/src.rb', line 610 def type end |