From: Michael Neumann Date: 2002-07-09T03:17:12+09:00 Subject: Re: Ruby.DBI -- select where ... On Tue, Jul 09, 2002 at 01:10:36AM +0900, Mark Probert wrote: > Hi. > > This is a Ruby-DBI question. I am using 0.0.15 under ruby 1.6.6 (cygwin). > I am using ODBC to connect to a SQL 7 database. The connection and > test programs work fine. > > However, when I do: > > require 'dbi' > > dbh = DBI.connect('DBI:ODBC:pubs', 'bob', 'bob') > state = "CA" > sth = dbh.prepare("select au_lname, au_fname from authors where state = #{state}") > sth.execute Better write: sth = dbh.prepare("select au_lname, au_fname from authors where state = ?") sth.execute(state) or even shorter: dbh.execute("select au_lname, au_fname from authors where state = ?", state) Regards, Michael