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