From: Maung Aung Date: 2007-06-28T01:43:38+09:00 Subject: Re: how to get data from database as string Thank you for your response, Brian. Actually what i am trying to do is that use the string value I get from DB as an argument in another statement. eg: conn = OCI8.new('user', 'pwd', 'testingDB.com') cursor=conn.exec("Select name From empl Where ssn=123456789) while r = cursor.fetch() r end cursor.close conn.logoff myLogin1 = Login.new myLogin1.setup("http://www.testing.com/", *****, "pwd") ***** this is where i want to put the string value from DB. That's supposed to be a user name. How could i do that? I have spent so much time on it. Could anyone help? Thanks, Maung Brian Candler wrote: >> How can i read a cell from database and retrieve as a string in ruby >> with OCI8? > > There are working examples in the documentation at > http://ruby-oci8.rubyforge.org/ > > Click on "ruby-oci8 API" on the left-hand side, e.g. to get to > http://ruby-oci8.rubyforge.org/en/api_OCI8Cursor.html#l9 > > Basically you need to call fetch or fetch_hash on your cursor to get the > results from the select statement. > > Alternatively, if you call exec() directly on the OCI8 object, you can > pass > a block. The one-liner example on the front page demonstrates this: > > OCI8.new('scott', 'tiger').exec('select * from emp') do |r| puts > r.join(','); end > > HTH, > > Brian. -- Posted via http://www.ruby-forum.com/.