Class: SQLAnywhere::SQLAnywhereInterface

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/sql_anywhere_interface.rb

Instance Method Summary collapse

Instance Method Details

#sqlany_describe_bind_param(statement, index) ⇒ Object



78
79
80
81
82
# File 'lib/sql_anywhere_interface.rb', line 78

def sqlany_describe_bind_param(statement, index)
  bind_parameter = SQLAnywhere::BindParam.new
  result = sqlany_describe_bind_param_(statement, index, bind_parameter)
  [result, bind_parameter]
end

#sqlany_disconnect(connection) ⇒ Object



50
51
52
53
# File 'lib/sql_anywhere_interface.rb', line 50

def sqlany_disconnect(connection)
  sqlany_disconnect_(connection)
  return nil
end

#sqlany_error(connection) ⇒ Object



20
21
22
23
24
25
# File 'lib/sql_anywhere_interface.rb', line 20

def sqlany_error(connection)
  size = 255
  buffer = FFI::MemoryPointer.new(:char, size, false)
  code = sqlany_error_ connection, buffer, size
  return code, buffer.read_string
end

#sqlany_get_column(statement, column_number) ⇒ Object



35
36
37
38
39
40
# File 'lib/sql_anywhere_interface.rb', line 35

def sqlany_get_column(statement, column_number)
  buffer = SQLAnywhere::DataValue.new
  result = sqlany_get_column_(statement, column_number, buffer)
  return [0, nil] if result == 0
  [result, buffer.value]
end

#sqlany_get_column_info(statement, column_number) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/sql_anywhere_interface.rb', line 89

def sqlany_get_column_info(statement, column_number)

  info = SQLAnywhere::ColumnInfo.new
  
  result = sqlany_get_column_info_(statement, column_number, info)
  [result, column_number, info[:name], info[:type], info[:native_type], info[:precision], info[:scale], info[:max_size], info[:nullable].read]
end

#sqlany_init(app_name = "RUBY", api_version = SQLAnywhere::API_VERSION_2, version_available = FFI::MemoryPointer.new(:int, 1, false)) ⇒ Object



8
9
10
# File 'lib/sql_anywhere_interface.rb', line 8

def sqlany_init(app_name = "RUBY", api_version = SQLAnywhere::API_VERSION_2, version_available = FFI::MemoryPointer.new(:int, 1, false))
  sqlany_init_ app_name, api_version, version_available
end

#sqlany_sqlstate(connection) ⇒ Object



99
100
101
102
103
104
# File 'lib/sql_anywhere_interface.rb', line 99

def sqlany_sqlstate(connection)
  size = 255
  buffer = FFI::MemoryPointer.new(:char, size, false)
  used = sqlany_sqlstate_(connection, buffer, size)
  buffer.read_string(used)
end