Class: DB2::Environment
- Inherits:
-
Object
- Object
- DB2::Environment
- Includes:
- DB2Util
- Defined in:
- lib/active_record/vendor/db2.rb
Instance Method Summary collapse
- #data_sources(buffer_length = 1024) ⇒ Object
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
Methods included from DB2Util
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
28 29 30 31 32 |
# File 'lib/active_record/vendor/db2.rb', line 28 def initialize @handle_type = SQL_HANDLE_ENV rc, @handle = SQLAllocHandle(@handle_type, SQL_NULL_HANDLE) check_rc(rc) end |
Instance Method Details
#data_sources(buffer_length = 1024) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/active_record/vendor/db2.rb', line 34 def data_sources(buffer_length = 1024) retval = [] max_buffer_length = buffer_length a = SQLDataSources(@handle, SQL_FETCH_FIRST, SQL_MAX_DSN_LENGTH + 1, buffer_length) retval << [a[1], a[3]] max_buffer_length = [max_buffer_length, a[4]].max loop do a = SQLDataSources(@handle, SQL_FETCH_NEXT, SQL_MAX_DSN_LENGTH + 1, buffer_length) break if a[0] == SQL_NO_DATA_FOUND retval << [a[1], a[3]] max_buffer_length = [max_buffer_length, a[4]].max end if max_buffer_length > buffer_length get_data_sources(max_buffer_length) else retval end end |