Class: Sequel::DB2::Database
- Inherits:
-
Sequel::Database
- Object
- Sequel::Database
- Sequel::DB2::Database
- Includes:
- DB2CLI
- Defined in:
- lib/sequel/adapters/db2.rb
Constant Summary collapse
- TEMPORARY =
'GLOBAL TEMPORARY '.freeze
Constants inherited from Sequel::Database
Sequel::Database::ADAPTERS, Sequel::Database::AUTOINCREMENT, Sequel::Database::CASCADE, Sequel::Database::COLUMN_DEFINITION_ORDER, Sequel::Database::COMMA_SEPARATOR, Sequel::Database::MSSQL_DEFAULT_RE, Sequel::Database::MYSQL_TIMESTAMP_RE, Sequel::Database::NOT_NULL, Sequel::Database::NO_ACTION, Sequel::Database::NULL, Sequel::Database::POSTGRES_DEFAULT_RE, Sequel::Database::PRIMARY_KEY, Sequel::Database::RESTRICT, Sequel::Database::SET_DEFAULT, Sequel::Database::SET_NULL, Sequel::Database::SQL_BEGIN, Sequel::Database::SQL_COMMIT, Sequel::Database::SQL_RELEASE_SAVEPOINT, Sequel::Database::SQL_ROLLBACK, Sequel::Database::SQL_ROLLBACK_TO_SAVEPOINT, Sequel::Database::SQL_SAVEPOINT, Sequel::Database::STRING_DEFAULT_RE, Sequel::Database::TRANSACTION_BEGIN, Sequel::Database::TRANSACTION_COMMIT, Sequel::Database::TRANSACTION_ISOLATION_LEVELS, Sequel::Database::TRANSACTION_ROLLBACK, Sequel::Database::UNDERSCORE, Sequel::Database::UNIQUE, Sequel::Database::UNSIGNED
Instance Attribute Summary
Attributes inherited from Sequel::Database
#default_schema, #log_warn_duration, #loggers, #opts, #pool, #prepared_statements, #sql_log_level, #transaction_isolation_level
Instance Method Summary collapse
-
#connect(server) ⇒ Object
check_error(rc, “Could not allocate DB2 environment”).
- #dataset(opts = nil) ⇒ Object
- #execute(sql, opts = {}) ⇒ Object (also: #do)
- #test_connection(server = nil) ⇒ Object
Methods inherited from Sequel::Database
#<<, #[], adapter_class, #adapter_scheme, adapter_scheme, #add_column, #add_index, #add_servers, #alter_table, #call, #cast_type_literal, connect, #create_or_replace_view, #create_table, #create_table!, #create_table?, #create_view, #database_type, #disconnect, #drop_column, #drop_index, #drop_table, #drop_view, #dump_indexes_migration, #dump_schema_migration, #dump_table_schema, #each_server, #execute_ddl, #execute_dui, #execute_insert, #fetch, #from, #get, identifier_input_method, #identifier_input_method, identifier_input_method=, #identifier_input_method=, #identifier_output_method, identifier_output_method, identifier_output_method=, #identifier_output_method=, #indexes, #initialize, #inspect, #literal, #log_info, #log_yield, #logger=, #query, quote_identifiers=, #quote_identifiers=, #quote_identifiers?, #remove_servers, #rename_column, #rename_table, #run, #schema, #select, #serial_primary_key_options, #servers, #set_column_default, #set_column_type, single_threaded=, #single_threaded?, #supports_create_table_if_not_exists?, #supports_prepared_transactions?, #supports_savepoints?, #supports_transaction_isolation_levels?, #synchronize, #table_exists?, #tables, #transaction, #typecast_value, #uri, #url, #views
Methods included from Metaprogramming
Constructor Details
This class inherits a constructor from Sequel::Database
Instance Method Details
#connect(server) ⇒ Object
check_error(rc, “Could not allocate DB2 environment”)
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sequel/adapters/db2.rb', line 15 def connect(server) opts = server_opts(server) rc, dbc = SQLAllocHandle(SQL_HANDLE_DBC, @@env) check_error(rc, "Could not allocate database connection") rc = SQLConnect(dbc, opts[:database], opts[:user], opts[:password]) check_error(rc, "Could not connect to database") dbc end |
#dataset(opts = nil) ⇒ Object
31 32 33 |
# File 'lib/sequel/adapters/db2.rb', line 31 def dataset(opts = nil) DB2::Dataset.new(self, opts) end |
#execute(sql, opts = {}) ⇒ Object Also known as: do
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sequel/adapters/db2.rb', line 35 def execute(sql, opts={}) synchronize(opts[:server]) do |conn| rc, sth = SQLAllocHandle(SQL_HANDLE_STMT, @handle) check_error(rc, "Could not allocate statement") begin rc = log_yield(sql){SQLExecDirect(sth, sql)} check_error(rc, "Could not execute statement") yield(sth) if block_given? rc, rpc = SQLRowCount(sth) check_error(rc, "Could not get RPC") rpc ensure rc = SQLFreeHandle(SQL_HANDLE_STMT, sth) check_error(rc, "Could not free statement") end end end |
#test_connection(server = nil) ⇒ Object
26 27 28 29 |
# File 'lib/sequel/adapters/db2.rb', line 26 def test_connection(server=nil) synchronize(server){|conn|} true end |