--- !ruby/object:RI::MethodDescription 
aliases: []

block_params: 
comment: 
- !ruby/struct:SM::Flow::P 
  body: Creates a new aggregate function for use in SQL statements. Aggregate functions are functions that apply over every row in the result set, instead of over just a single row. (A very common aggregate function is the &quot;count&quot; function, for determining the number of rows that match a query.)
- !ruby/struct:SM::Flow::P 
  body: The new function will be added as <tt>name</tt>, with the given <tt>arity</tt>. (For variable arity functions, use -1 for the arity.)
- !ruby/struct:SM::Flow::P 
  body: The <tt>step</tt> parameter must be a proc object that accepts as its first parameter a FunctionProxy instance (representing the function invocation), with any subsequent parameters (up to the function's arity). The <tt>step</tt> callback will be invoked once for each row of the result set.
- !ruby/struct:SM::Flow::P 
  body: The <tt>finalize</tt> parameter must be a <tt>proc</tt> object that accepts only a single parameter, the FunctionProxy instance representing the current function invocation. It should invoke FunctionProxy#set_result to store the result of the function.
- !ruby/struct:SM::Flow::P 
  body: "Example:"
- !ruby/struct:SM::Flow::VERB 
  body: "  db.create_aggregate( &quot;lengths&quot;, 1 ) do\n    step do |func, value|\n      func[ :total ] ||= 0\n      func[ :total ] += ( value ? value.length : 0 )\n    end\n\n    finalize do |func|\n      func.set_result( func[ :total ] || 0 )\n    end\n  end\n\n  puts db.get_first_value( &quot;select lengths(name) from table&quot; )\n"
- !ruby/struct:SM::Flow::P 
  body: "See also #create_aggregate_handler for a more object-oriented approach to aggregate functions."
full_name: SQLite3::Database#create_aggregate
is_singleton: false
name: create_aggregate
params: ( name, arity, step=nil, finalize=nil, text_rep=Constants::TextRep::ANY, &block )
visibility: public
