ruby-oci8 question

B

beny 18241

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
 
P

Patrick Okui

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
 
P

Patrick Okui

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ruby-oci8 function 9
[ANN] ruby-oci8 1.0.1 4
Confused about OCI8 7
oracle oci8 utf8 corruption 1
[ANN] ruby-oci8 0.1.10 4
ruby problem connecting to oracle using oci8 0
Syntax error 4
[ANN] ruby-oci8 1.0.0 0

Members online

Forum statistics

Threads
474,169
Messages
2,570,918
Members
47,458
Latest member
Chris#

Latest Threads

Top