From: Yuriy Skobov on
Hi,
I'm just learning Ruby with SQLite3 and I ran into this problem with the
tutorial. After creating a database using this:

$db = SQLite3::Database.new("dbfile")
$db.results_as_hash = true
def create_table
puts "Creating people table"
$db.execute %q{
CREATE TABLE people (
id integer primary key,
name varchar(50),
job varchar(50),
gender varchar(6),
age integer)
}
end

I use the following to insert a new row into the database:

$db.execute("INSERT INTO people ( name, job, gender, age ) VALUES ( ?,
?, ?, ? )", name, job, gender, age)

However, the first value (name, in this case) gets ignored and is still
assigned NIL when this is done. I've tried hardcoding the first value
using \"Some Name\", but then the second seems to have the same problem
instead, so I'm pretty sure it's something with the placeholders.

Any idea what this might be? I thought I might be typing something
wrong, but after downloading and running the supplied source code
(attached), I got the same problem.

Attachments:
http://www.ruby-forum.com/attachment/4816/listing20.rb

--
Posted via http://www.ruby-forum.com/.

From: Yuriy Skobov on
I thought it might have been a Windows vs. Cygwin issue, so I went back
to Cygwin on this one. Had a lot of not_fun because there was
interference with the Windows installation of Ruby. However, once I got
Cygwin back on track (after uninstalling Windows installation of Ruby),
I saw the same problem.
I'm using:
Windows 7 64-bit
sqlite3-ruby (1.3.0)
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]

Should I try to match your version and see if that works?
--
Posted via http://www.ruby-forum.com/.