class SQLite3::Database
def create_function(name, arity, text_rep = Constants::TextRep::ANY, &block) # :yields: func, *args
puts db.get_first_value("select maim(name) from table")
end
end
func.result = value.split(//).sort.join
else
func.result = nil
if value.nil?
db.create_function("maim", 1) do |func, value|
Example:
indicate the return value that way.
the FunctionProxy#set_result method on the +func+ parameter and
The block does not return a value directly. Instead, it will invoke
arguments it needs (up to its arity).
instance that wraps this function invocation--and any other
The block should accept at least one parameter--the FunctionProxy
-1 for the arity.)
+name+, with the given +arity+. (For variable arity functions, use
Creates a new function for use in SQL statements. It will be added as
def create_function(name, arity, text_rep = Constants::TextRep::ANY, &block) # :yields: func, *args # begin callback = proc do |func, *args| begin block.call(FunctionProxy.new(@driver, func), *args.map { |v| Value.new(self, v) }) rescue StandardError, Exception => e @driver.result_error(func, "#{e.message} (#{e.class})", -1) end end result = @driver.create_function(@handle, name, arity, text_rep, nil, callback, nil, nil) Error.check(result, self) self end