Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Gerardo Santana Gómez Garrido
RE: Informix Ruby connection test failing [ reply ]  
2008-05-28 18:18
yes

By: Lotus Shree
RE: Informix Ruby connection test failing [ reply ]  
2008-05-28 15:26
so it has to match the server name specified in SetNet?

By: Gerardo Santana Gómez Garrido
RE: Informix Ruby connection test failing [ reply ]  
2008-05-27 16:28
Sure.

Just use the server name that you specified in SetNet32


dbtest = Informix.connect('dbname@testserv')
dbprod = Informix.connect('dbname@prodserv')

By: Lotus Shree
RE: Informix Ruby connection test failing [ reply ]  
2008-05-27 15:50
Thanks that helped...

One more question on db connect.

Depending on testing need I need to connect to test server or production server. With informix server information is setup in setnet.

Is there a way to sepecify server info on dbconnect call based on testing needs


thanks...


By: Gerardo Santana Gómez Garrido
RE: Informix Ruby connection test failing [ reply ]  
2008-05-14 18:36
The "prepare" method cannot be used for retrieving more than one record. You can verify this and other Ruby/Informix behaviors here:

http://ruby-informix.rubyforge.org/doc/

The behavior of "prepare" is here:
http://ruby-informix.rubyforge.org/doc/classes/Informix/Database.html#M000114

What you want is a cursor, which can be created using Database#cursor, like this:

cur = @db.cursor('select name from NameTable')
cur.open
record = cur.fetch
puts record[0]
record = cur.fetch
puts record[0]
cur.close

I find the above code ugly, though. You can do better with the shortcuts provided by Ruby/Informix:

@db.each_hash('select name from NameTable') do |record|
puts record['name']
end

The above code prints the "name" field of every record in NameTable.

Check the documentation to find better ways to accomplish your goals.

By: Lotus Shree
RE: Informix Ruby connection test failing [ reply ]  
2008-05-14 18:11
You are right I was missing ruby-informix gem.
I am able to connect to database now.

I am connecting to database using

@db=Informix.connect('dbname','uid', 'pwd')
successfully create new table and inserted values.

but when tried to select value getting,
Informix::DatabaseError: Cardinality violation
tc__testdb_connect.rb:31:in `execute'

I am able to access the table and select row with the same userid/pwd though db access tool. Do I need to provide severname, hostname in connect string?


def test_select_table
stmt= @db.prepare('select name from NameTable')
record= stmt.execute()
puts record.fetch(0)
puts record.fetch(1)

end

thanks....

By: Gerardo Santana Gómez Garrido
RE: Informix Ruby connection test failing [ reply ]  
2008-05-09 21:25
Hi Lotus.

The error message says that Rubygems didn't found ruby-informix

Verify that ruby-informix is installed by running

gem list

By: Lotus Shree
Informix Ruby connection test failing [ reply ]  
2008-05-09 19:26
Hi,

I am trying to test informix DB connection thorugh ruby. I worked before but now getting following error

c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_re
quire': no such file to load -- informix (LoadError)
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `re
quire'
from tc__testdb_connect.rb:2


Here is source code
--------
require 'rubygems'
require 'informix'
require 'test/unit'



class TC_TestDBConnect < Test::Unit::TestCase

def setup
@db=Informix.connect('testdb','tester', '1234')
end

def test_create_table

@db.execute('create table NameTable(id integer, name char(20))') end

# def test_drop_table
# @db.execute('drop table NameTable')
# end

def test_insert_table
stmt = @db.prepare('insert into NameTable values(3,"Kingkong")')
stmt.execute

end

end
------------

Have following

1) ruby-informix-0.7.1.gem
2)ruby-informix-0.7.1-i386-mswin32.gem
3)ruby-informix-0.7.1


Thanks,
-
Shree