Class Sequel::DB2::Database
In: lib/sequel_core/adapters/db2.rb
Parent: Sequel::Database

Methods

connect   dataset   do   execute   test_connection  

Included Modules

DB2CLI

Public Instance methods

check_error(rc, "Could not allocate DB2 environment")

[Source]

    # 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

[Source]

    # File lib/sequel_core/adapters/db2.rb, line 28
28:       def dataset(opts = nil)
29:         DB2::Dataset.new(self, opts)
30:       end
do(sql, opts={})

Alias for execute

[Source]

    # 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

[Source]

    # File lib/sequel_core/adapters/db2.rb, line 23
23:       def test_connection(server=nil)
24:         synchronize(server){|conn|}
25:         true
26:       end

[Validate]