Class | Sequel::DB2::Database |
In: |
lib/sequel/adapters/db2.rb
|
Parent: | Sequel::Database |
TEMPORARY | = | 'GLOBAL TEMPORARY '.freeze |
check_error(rc, "Could not allocate DB2 environment")
# File lib/sequel/adapters/db2.rb, line 15 15: def connect(server) 16: opts = server_opts(server) 17: rc, dbc = SQLAllocHandle(SQL_HANDLE_DBC, @@env) 18: check_error(rc, "Could not allocate database connection") 19: 20: rc = SQLConnect(dbc, opts[:database], opts[:user], opts[:password]) 21: check_error(rc, "Could not connect to database") 22: 23: dbc 24: end
# File lib/sequel/adapters/db2.rb, line 31 31: def dataset(opts = nil) 32: DB2::Dataset.new(self, opts) 33: end
# File lib/sequel/adapters/db2.rb, line 35 35: def execute(sql, opts={}) 36: log_info(sql) 37: synchronize(opts[:server]) do |conn| 38: rc, sth = SQLAllocHandle(SQL_HANDLE_STMT, @handle) 39: check_error(rc, "Could not allocate statement") 40: 41: begin 42: rc = SQLExecDirect(sth, sql) 43: check_error(rc, "Could not execute statement") 44: 45: yield(sth) if block_given? 46: 47: rc, rpc = SQLRowCount(sth) 48: check_error(rc, "Could not get RPC") 49: rpc 50: ensure 51: rc = SQLFreeHandle(SQL_HANDLE_STMT, sth) 52: check_error(rc, "Could not free statement") 53: end 54: end 55: end