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 = nil) { ... }

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

Parameters:

  • sql (String) (defaults to: nil)
    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)

Raises:

  • (ArgumentError)


108
109
110
111
112
113
114
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 108

def call(sql=nil)
  if sql.class == String && block_given?
    @j_del.java_method(:call, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling call(#{sql})"
end

- (self) call_with_params(sql = nil, params = nil, outputs = nil) { ... }

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) (defaults to: nil)
    the SQL to execute. For example {call getEmpName (?, ?)}.
  • params (Array<String,Object>) (defaults to: nil)
    these are the parameters to fill the statement.
  • outputs (Array<String,Object>) (defaults to: nil)
    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)

Raises:

  • (ArgumentError)


129
130
131
132
133
134
135
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 129

def call_with_params(sql=nil,params=nil,outputs=nil)
  if sql.class == String && params.class == Array && outputs.class == Array && 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(sql,::Vertx::Util::Utils.to_json_array(params),::Vertx::Util::Utils.to_json_array(outputs),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling call_with_params(#{sql},#{params},#{outputs})"
end

- (self) query(sql = nil) { ... }

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

Parameters:

  • sql (String) (defaults to: nil)
    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)

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 10

def query(sql=nil)
  if sql.class == String && block_given?
    @j_del.java_method(:query, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling query(#{sql})"
end

- (self) query_single(sql = nil) { ... }

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) (defaults to: nil)
    the statement to execute

Yields:

  • the result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


58
59
60
61
62
63
64
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 58

def query_single(sql=nil)
  if sql.class == String && block_given?
    @j_del.java_method(:querySingle, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling query_single(#{sql})"
end

- (self) query_single_with_params(sql = nil, arguments = nil) { ... }

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) (defaults to: nil)
    the statement to execute
  • arguments (Array<String,Object>) (defaults to: nil)
    the arguments

Yields:

  • the result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


72
73
74
75
76
77
78
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 72

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

- (self) query_stream(sql = nil) { ... }

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

Parameters:

  • sql (String) (defaults to: nil)
    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)

Raises:

  • (ArgumentError)


33
34
35
36
37
38
39
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 33

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

- (self) query_stream_with_params(sql = nil, params = nil) { ... }

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

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example SELECT * FROM table ....
  • params (Array<String,Object>) (defaults to: nil)
    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)

Raises:

  • (ArgumentError)


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 45

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

- (self) query_with_params(sql = nil, params = nil) { ... }

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

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example SELECT * FROM table ....
  • params (Array<String,Object>) (defaults to: nil)
    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)

Raises:

  • (ArgumentError)


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 22

def query_with_params(sql=nil,params=nil)
  if sql.class == String && params.class == Array && block_given?
    @j_del.java_method(:queryWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(params),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling query_with_params(#{sql},#{params})"
end

- (self) update(sql = nil) { ... }

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

Parameters:

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

Yields:

  • the handler which is called once the operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


84
85
86
87
88
89
90
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 84

def update(sql=nil)
  if sql.class == String && block_given?
    @j_del.java_method(:update, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling update(#{sql})"
end

- (self) update_with_params(sql = nil, params = nil) { ... }

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

Parameters:

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

Yields:

  • the handler which is called once the operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


97
98
99
100
101
102
103
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_operations.rb', line 97

def update_with_params(sql=nil,params=nil)
  if sql.class == String && params.class == Array && block_given?
    @j_del.java_method(:updateWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(params),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling update_with_params(#{sql},#{params})"
end