Module: VertxSql::SQLOperations

Included in:
SQLClient, SQLConnection, SQLOperationsImpl
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb

Instance Method Summary (collapse)

Instance Method Details

- (self) call(sql, resultHandler) { ... }

Calls the given SQL PROCEDURE which returns the result from the procedure.

Parameters:

  • sql (String)
    the SQL to execute. For example {call getEmpName}.

Yields:

  • the handler which is called once the operation completes. It will return a ResultSet.

Returns:

  • (self)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 12

def call(*args)
  if args[0].class == String && true
    if (block_given?)
      @j_del.java_method(:call, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:call, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Util::data_object_type(Java::IoVertxExtSql::ResultSet))
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling call(#{args[0]})"
  end
end

- (self) callWithParams(sql, params, outputs, resultHandler) { ... }

Calls the given SQL PROCEDURE which returns the result from the procedure. The index of params and outputs are important for both arrays, for example when dealing with a prodecure that takes the first 2 arguments as input values and the 3 arg as an output then the arrays should be like:

   params = [VALUE1, VALUE2, null]
   outputs = [null, null, "VARCHAR"]

Parameters:

  • sql (String)
    the SQL to execute. For example {call getEmpName (?, ?)}.
  • params (Array<String,Object>)
    these are the parameters to fill the statement.
  • outputs (Array<String,Object>)
    these are the outputs to fill the statement.

Yields:

  • the handler which is called once the operation completes. It will return a ResultSet.

Returns:

  • (self)


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 67

def call_with_params(*args)
  if args[0].class == String && args[1].class == Array && args[2].class == Array && true
    if (block_given?)
      @j_del.java_method(:callWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),::Vertx::Util::Utils.to_json_array(args[2]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:callWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),::Vertx::Util::Utils.to_json_array(args[2]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Util::data_object_type(Java::IoVertxExtSql::ResultSet))
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling call_with_params(#{args[0]},#{args[1]},#{args[2]})"
  end
end

- (self) query(sql, resultHandler) { ... }

Executes the given SQL SELECT statement which returns the results of the query.

Parameters:

  • sql (String)
    the SQL to execute. For example SELECT * FROM table ....

Yields:

  • the handler which is called once the operation completes. It will return a ResultSet.

Returns:

  • (self)


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 113

def query(*args)
  if args[0].class == String && true
    if (block_given?)
      @j_del.java_method(:query, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:query, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Util::data_object_type(Java::IoVertxExtSql::ResultSet))
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling query(#{args[0]})"
  end
end

- (self) querySingle(sql, handler) { ... }

Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

Parameters:

  • sql (String)
    the statement to execute

Yields:

  • the result handler

Returns:

  • (self)


137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 137

def query_single(*args)
  if args[0].class == String && true
    if (block_given?)
      @j_del.java_method(:querySingle, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:querySingle, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling query_single(#{args[0]})"
  end
end

- (self) querySingleWithParams(sql, arguments, handler) { ... }

Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

Parameters:

  • sql (String)
    the statement to execute
  • arguments (Array<String,Object>)
    the arguments

Yields:

  • the result handler

Returns:

  • (self)


185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 185

def query_single_with_params(*args)
  if args[0].class == String && args[1].class == Array && true
    if (block_given?)
      @j_del.java_method(:querySingleWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:querySingleWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling query_single_with_params(#{args[0]},#{args[1]})"
  end
end

- (self) queryStream(sql, handler) { ... }

Executes the given SQL SELECT statement which returns the results of the query as a read stream.

Parameters:

  • sql (String)
    the SQL to execute. For example SELECT * FROM table ....

Yields:

  • the handler which is called once the operation completes. It will return a SQLRowStream.

Returns:

  • (self)


230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 230

def query_stream(*args)
  if args[0].class == String && true
    if (block_given?)
      @j_del.java_method(:queryStream, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSql::SQLRowStream) : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:queryStream, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSql::SQLRowStream) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::VertxSql::SQLRowStream.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling query_stream(#{args[0]})"
  end
end

- (self) queryStreamWithParams(sql, params, handler) { ... }

Executes the given SQL SELECT statement which returns the results of the query as a read stream.

Parameters:

  • sql (String)
    the SQL to execute. For example SELECT * FROM table ....
  • params (Array<String,Object>)
    these are the parameters to fill the statement.

Yields:

  • the handler which is called once the operation completes. It will return a SQLRowStream.

Returns:

  • (self)


208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 208

def query_stream_with_params(*args)
  if args[0].class == String && args[1].class == Array && true
    if (block_given?)
      @j_del.java_method(:queryStreamWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSql::SQLRowStream) : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:queryStreamWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSql::SQLRowStream) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::VertxSql::SQLRowStream.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling query_stream_with_params(#{args[0]},#{args[1]})"
  end
end

- (self) queryWithParams(sql, params, resultHandler) { ... }

Executes the given SQL SELECT prepared statement which returns the results of the query.

Parameters:

  • sql (String)
    the SQL to execute. For example SELECT * FROM table ....
  • params (Array<String,Object>)
    these are the parameters to fill the statement.

Yields:

  • the handler which is called once the operation completes. It will return a ResultSet.

Returns:

  • (self)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 35

def query_with_params(*args)
  if args[0].class == String && args[1].class == Array && true
    if (block_given?)
      @j_del.java_method(:queryWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:queryWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Util::data_object_type(Java::IoVertxExtSql::ResultSet))
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling query_with_params(#{args[0]},#{args[1]})"
  end
end

- (self) update(sql, resultHandler) { ... }

Executes the given SQL statement which may be an INSERT, UPDATE, or DELETE statement.

Parameters:

  • sql (String)
    the SQL to execute. For example INSERT INTO table ...

Yields:

  • the handler which is called once the operation completes.

Returns:

  • (self)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 160

def update(*args)
  if args[0].class == String && true
    if (block_given?)
      @j_del.java_method(:update, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:update, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Util::data_object_type(Java::IoVertxExtSql::UpdateResult))
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling update(#{args[0]})"
  end
end

- (self) updateWithParams(sql, params, resultHandler) { ... }

Executes the given prepared statement which may be an INSERT, UPDATE, or DELETE statement with the given parameters

Parameters:

  • sql (String)
    the SQL to execute. For example INSERT INTO table ...
  • params (Array<String,Object>)
    these are the parameters to fill the statement.

Yields:

  • the handler which is called once the operation completes.

Returns:

  • (self)


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 91

def update_with_params(*args)
  if args[0].class == String && args[1].class == Array && true
    if (block_given?)
      @j_del.java_method(:updateWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:updateWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Util::data_object_type(Java::IoVertxExtSql::UpdateResult))
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling update_with_params(#{args[0]},#{args[1]})"
  end
end