From: mavallad@... (Manuel Valladares) Date: 2002-11-12T08:27:35+09:00 Subject: Problem with a select in Oracle Hello, I am just beginning in Ruby, in fact this is my first script. I need to copy values from a comma separated file to an Oracle database and just to try I would like to do it in Ruby. I installed the ruby dbi and oracle drivers and everything looks looked it was working fine, until now that I want to retrieve the e-mail addresses from the database. The code I am using is this one: ######################################################################## require 'dbi' require 'oracle' # Open the files contactFile = File.open("contact_sel.csv","r") logFile = File.new("contact.log","w") # Connect to the database dbConnect = DBI.connect('DBI:Oracle:limsod', 'lims', 'mjd0340854') #Prepare the statement sql = "SELECT client_id, contact_id, name, type, email " + "FROM contact_table " + "WHERE client_id = :ci_id " + "AND contact_id = :co_id " + "AND email IS NOT NULL" dbQuery = dbConnect.prepare(sql) begin while (line = contactFile.readline()) client_id, contact_id, status, email, phone = line.split(/\s*\,\s*/) dbQuery.bind_param("ci_id", client_id) dbQuery.bind_param("co_id", contact_id) dbQuery.execute() if (row = dbQuery.fetch()) logFile.print("Client: " + client_id + " Contact: " + contact_id + " is present\n") if (!(row[1] == "")) logFile.print("++ Contact: #{row[1]} e-mail: #{row[3]} Name: #{row[2]}\n") end else logFile.print("Contact: " + contact_id + " not present\n") end end logFile.print("END\n") rescue EOFError contactFile.close() end # Disconnect to the database dbConnect.disconnect() ##################################################################### Well, the problem is that I am not getting the values that are in the database. There are a bunch of records with email not null, but the script gets only one record with garbage in the email part. So I don't understand what is wrong. Is there any problem with the '@' symbol? I am able to get the values from the rest of the fields, but not the email field. It looks weird to me. If this doesn't work I will not use Ruby because need the Oracle connection to do my scripts. That's it. Thank you very much for your help Manuel Valladares