Steven Arnold
2005-Aug-28 01:50 UTC
[sqlite-ruby-users] set_value undefined in user-defined function?
Hi,
I am running what I think should be a very straightforward script
lifted almost verbatim from the documentation (http://sqlite-
ruby.rubyforge.org/classes/SQLite/Database.html#M000089). Below is
the script output, the script itself, and the sqlite version
information. The platform is Mac OS X 10.4.2. Any thoughts on why
this does not work and what changes must be made to correct it?
steve
[thoth@omega:~] > ruby sqlitefn.rb
/usr/local/lib/ruby/site_ruby/1.8/sqlite/resultset.rb:73:in `step'':
undefined method `set_value'' for #<SQLite::Database::FunctionProxy:
0x35bb08> (NoMethodError) (SQLite::Exceptions::SQLException)
from /usr/local/lib/ruby/site_ruby/1.8/sqlite/resultset.rb:
73:in `commence''
from /usr/local/lib/ruby/site_ruby/1.8/sqlite/resultset.rb:
65:in `initialize''
from /usr/local/lib/ruby/site_ruby/1.8/sqlite/statement.rb:
104:in `new''
from /usr/local/lib/ruby/site_ruby/1.8/sqlite/statement.rb:
104:in `execute''
from /usr/local/lib/ruby/site_ruby/1.8/sqlite/database.rb:
194:in `execute''
from /usr/local/lib/ruby/site_ruby/1.8/sqlite/database.rb:
276:in `get_first_value''
from sqlitefn.rb:12
[thoth@omega:~] > cat sqlitefn.rb
require ''sqlite''
include SQLite
SQLITEDB = ''/Users/thoth/Source/new_dictionary/rubydict/kantrik-
sqlite.db''
db = SQLite::Database.new(SQLITEDB)
db.create_function( "maim", 1, :text ) do |func, value|
if value.nil?
func.set_value nil
else
func.set_value value.split(//).sort.join
end
end
db.get_first_value("select maim(word) from words")
[thoth@omega:~] > sqlite -version
2.8.16