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

### Methods

connect dataset do execute test_connection

### Included Modules

DB2CLI

### Constants

TEMPORARY | = | 'GLOBAL TEMPORARY '.freeze

### Public Instance methods

connect(server)

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

[Source]

        # 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

dataset(opts = nil)

[Source]

        # File lib/sequel/adapters/db2.rb, line 31
    31:       def dataset(opts = nil)
    32:         DB2::Dataset.new(self, opts)
    33:       end

do(sql, opts={})

Alias for execute

execute(sql, opts={}) {|sth| ...}

[Source]

        # 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

test_connection(server=nil)

[Source]

        # File lib/sequel/adapters/db2.rb, line 26
    26:       def test_connection(server=nil)
    27:         synchronize(server){|conn|}
    28:         true
    29:       end

[Validate]