Class: Sequel::DB2::Database

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:         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

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]