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: synchronize(opts[:server]) do |conn| 37: rc, sth = SQLAllocHandle(SQL_HANDLE_STMT, @handle) 38: check_error(rc, "Could not allocate statement") 39: 40: begin 41: rc = log_yield(sql){SQLExecDirect(sth, sql)} 42: check_error(rc, "Could not execute statement") 43: 44: yield(sth) if block_given? 45: 46: rc, rpc = SQLRowCount(sth) 47: check_error(rc, "Could not get RPC") 48: rpc 49: ensure 50: rc = SQLFreeHandle(SQL_HANDLE_STMT, sth) 51: check_error(rc, "Could not free statement") 52: end 53: end 54: end