Ruby-oci8 question

Hi,

I have some problem, i want to make select query with $name variable but
i cant, this is my code please help what is wrong

print “Enter name :”
$name = STDIN.gets

conn = OCI8.new(‘user’, ‘pass’)
num_rows = conn.exec(“SELECT * FROM test where name like '%” + $name +
“%’”)
do |r|
puts r.join(’,’)
end

On Sep 15, 2009, at 1:16 PM, beny 18241 wrote:

Hi,

I have some problem, i want to make select query with $name variable
but
i cant, this is my code please help what is wrong

print “Enter name :”
$name = STDIN.gets

this $name has a ‘\n’ in it, try STDIN.gets.chomp

On Sep 15, 2009, at 1:33 PM, beny 18241 wrote:

print “Enter name :”
$name = STDIN.gets

this $name has a ‘\n’ in it, try STDIN.gets.chomp

thanks works

You’re welcome. Also consider removing the ‘$’ and using the variable
as just “name” just like conn and num_rows (I’m guessing you’re from a
perl or php background).

Patrick O. wrote:

On Sep 15, 2009, at 1:16 PM, beny 18241 wrote:

Hi,

I have some problem, i want to make select query with $name variable
but
i cant, this is my code please help what is wrong

print “Enter name :”
$name = STDIN.gets

this $name has a ‘\n’ in it, try STDIN.gets.chomp

thanks works

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs