From: mavallad@... (Manuel Valladares) Date: 2002-11-13T01:50:01+09:00 Subject: Re: Problem with a select in Oracle I am sorry guys, You were absolutly right, there is nothing wrong with the '@' symbol. The problem is that I did something stupid and I was connecting to the wrong schema in Oracle, so of course I was getting different results than I was expecting. But thank you very much for the coding recommendations. Sorry again for wasting your time, Manuel Valladares mavallad@yahoo.es (Manuel Valladares) wrote in message news:<73e32e3a.0211111517.4af49211@posting.google.com>... > 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