[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

dbi placeholder problem

Wmute

5/26/2006 8:01:00 AM

Hello,

I have problems getting a simple SQL query to do what i want,

category="blabla"

sth= dbh.prepare("SELECT t_problem from ticket WHERE t_category = ? ")

sth.execute(category) (or sth.execute("#{category}"))

this returns nothing, but if i try with

sth.execute("blabla")

it works.

This works as expected in Perl

sth= dbh.prepare("SELECT t_problem from ticket WHERE t_category =
'$category' ")

Tried the same in Ruby

sth= dbh.prepare("SELECT t_problem from ticket WHERE t_category =
'#{category}' ")

It returns nothing, what am i doing wrong?

3 Answers

endy_tj

5/27/2006 3:59:00 AM

0

I have no problem with putting variable in sth.execute, but you still
need to do:

sth.fetch
or
sth.fetch_all

--
Endy

Wmute

5/29/2006 1:32:00 PM

0

Sorry, i am using

sth.execute("#{var}")

while row=sth.fetch do
p row

end


but still dont get any result, however when using

sth.execute("some_word")

the query works as it should,
using single qoutesdosent work either

sth.execute('#{var}')

what is wrong?

Matt

10/9/2008 6:03:00 AM

0

On Wed, 08 Oct 2008 20:06:29 -0700, john w <j<no>@yahoo.com> wrote:

>x-no-archive: yes
>On Tue, 07 Oct 2008 09:52:07 -0800, ..... Matt .....
><trdell1234@nosgmail.com > wrote:
> ? 2008 John D Weatherly all rights reserved; no portion of this post
>may be used anywhere else without written permission of the author.
>>On Tue, 07 Oct 2008 09:43:41 -0700, john w <j<no>@yahoo.com> wrote:
>>
>>>x-no-archive: yes
>>>On Mon, 06 Oct 2008 11:58:50 -0800, ..... Matt .....
>>><trdell1234@nosgmail.com > wrote:
>>> ? 2008 John D Weatherly all rights reserved; no portion of this post
>>>may be used anywhere else without written permission of the author.
>>>>On Mon, 6 Oct 2008 14:34:52 -0400, "Robibnikoff"
>>>><witchypoo@broomstick.com> wrote:
>>>>
>>>>>
>>>>>"john w @yahoo.com>" <j<no> simpered:
>>>>>
>>>>>>
>>>>>> Again, only according to your flawed logic.
>>>>>
>>>>>You appear to be off your meds, johnnie.
>>>>
>>>>
>>>>Think he has been for over a week.
>>>
>>> Now you're saying that anyone who disagrees with your childish rants
>>>is off their meds?
>>>
>>> Grow up.
>>>
>>>
>>
>>Yes Johnny we know that for me to agree with someone in another post
>>that I started was a rant. You also do seem to be getting worst in
>>the last few weeks.
>
> You wish me well, you say you'll pray for me, then you use a name
>for me you know I don't like.
>
> You effing Liar! You effing hypocrite!!

The more you attack me the better Christian I know I am


Thanks

Matt
>
>
>
>>
>>I pray you get better
>>
>>Matt
>>2 Peter 1:2
>>Grace and peace be yours in
>> abundance through the knowledge of God and of Jesus our Lord.