[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

trouble with sqlite-ruby

Lowell

6/20/2005 7:12:00 AM

I'm having trouble getting bind parameters to work. I'm getting errors
along the line of "no such bind parameter 'file' (SQLite3::Exception)".
This arises in 2 situations, which are probably both doing the same
thing under the hood. Here are the pices of code that give me the errors:

stmt = db.prepare("select * from mp3 where file = :file;")
stmt.bind_param('file', 'hello')
and

stmt = db.execute("select * from mp3 where file = :file;",
"file" => 'hello')

I don't know why Ruby thinks there is no such bind parameter as 'file'
when it's clearly there in the string.

Lowell
5 Answers

Jaypee

6/20/2005 7:24:00 PM

0

Lowell Kirsh a écrit :
> I'm having trouble getting bind parameters to work. I'm getting errors
> along the line of "no such bind parameter 'file' (SQLite3::Exception)".
> This arises in 2 situations, which are probably both doing the same
> thing under the hood. Here are the pices of code that give me the errors:
>
> stmt = db.prepare("select * from mp3 where file = :file;")
> stmt.bind_param('file', 'hello')
> and
>
> stmt = db.execute("select * from mp3 where file = :file;",
> "file" => 'hello')
>
> I don't know why Ruby thinks there is no such bind parameter as 'file'
> when it's clearly there in the string.
>
> Lowell
My little, tiny experience with SQLite3 is that it requires quote around
the tables and columns name. Have you tried this way:
stmt = db.prepare("select * from 'mp3' where 'file' = :file;")
J-P

Gyoung-Yoon Noh

6/20/2005 7:42:00 PM

0

On 6/20/05, Lowell Kirsh <lkirsh@cs.ubc.ca> wrote:
> I'm having trouble getting bind parameters to work. I'm getting errors
> along the line of "no such bind parameter 'file' (SQLite3::Exception)".
> This arises in 2 situations, which are probably both doing the same
> thing under the hood. Here are the pices of code that give me the errors:
>
> stmt = db.prepare("select * from mp3 where file = :file;")
> stmt.bind_param('file', 'hello')
> and
>
> stmt = db.execute("select * from mp3 where file = :file;",
> "file" => 'hello')
>
> I don't know why Ruby thinks there is no such bind parameter as 'file'
> when it's clearly there in the string.
>
> Lowell
>
>

It seems to be recognized as one token ':file;', not ':file' as you expected.
Omit semicolon(;), indeed, semicolon need not be there

Lowell

6/20/2005 8:57:00 PM

0

Jaypee wrote:
> My little, tiny experience with SQLite3 is that it requires quote around
> the tables and columns name. Have you tried this way:
> stmt = db.prepare("select * from 'mp3' where 'file' = :file;")
> J-P

Thanks, but I tried that and I'm still getting the same error. Any other
ideas?

Lowell

6/20/2005 8:58:00 PM

0

Gyoung-Yoon Noh wrote:
> It seems to be recognized as one token ':file;', not ':file' as you expected.
> Omit semicolon(;), indeed, semicolon need not be there

I removed the semicolon but I still get the same error. Any other ideas?
After a couple of hours of trying to figure this out, it's starting to
look like a bug in sqlite-ruby to me.

Jamis Buck

6/20/2005 9:09:00 PM

0

On Jun 20, 2005, at 3:00 PM, Lowell Kirsh wrote:

> Gyoung-Yoon Noh wrote:
>
>> It seems to be recognized as one token ':file;', not ':file' as
>> you expected.
>> Omit semicolon(;), indeed, semicolon need not be there
>>
>
> I removed the semicolon but I still get the same error. Any other
> ideas? After a couple of hours of trying to figure this out, it's
> starting to look like a bug in sqlite-ruby to me.
>
>

Yup, it's a bug. I can duplicate it, and I've got a failing test case
for it now, but I don't know _why_ it is failing, and I probably
won't have time to dig in and investigate it for a while. If anyone
manages to come up with a patch for this, I'd be very grateful.

- Jamis