From: gregarican Date: 2006-11-15T05:30:06+09:00 Subject: Re: Assoc method on large array Here it is: --------------------------------------------------- require 'dbi' dsn=DBI.connect('DBI:ADO:Provider=SQLOLEDB;Connect Timeout=5;Data Source=my_server;Initial Catalog=my_db;Persist Security Info=True;Trusted_Connection=Yes;') queryString = "SELECT C.CustNo, C.FullName, C.Street, C.City, C.State, C.zip, C.Phone " queryString << "from TblCustInfo C, TblCustMailOuts M " queryString << "where C.CustNo = M.CustNo " sqlStmt=dsn.prepare(queryString) sqlStmt.execute resultSet=sqlStmt.fetch_all match=resultSet.assoc(integerValue) --------------------------------------------------- My resultSet is an array and I can inspect its contents. The first element of each row of the array is an integer. When I try to do the resultSet.assoc() method to pull one of these out I always get nil. No matter what I do. Here's what I did that worked, however: --------------------------------------------------- require 'dbi' dsn=DBI.connect('DBI:ADO:Provider=SQLOLEDB;Connect Timeout=5;Data Source=my_server;Initial Catalog=my_db;Persist Security Info=True;Trusted_Connection=Yes;') queryString = "SELECT C.CustNo, C.FullName, C.Street, C.City, C.State, C.zip, C.Phone " queryString << "from TblCustInfo C, TblCustMailOuts M " queryString << "where C.CustNo = M.CustNo " sqlStmt=dsn.prepare(queryString) sqlStmt.execute resultSet=sqlStmt.fetch_all resultCustSet=[] resultSet.each { | row | resultCustSet << [row[0], row[1], row[2], row[3], row[4], row[5], row[6]] } match=resultCustSet.assoc(integerValue) --------------------------------------------------- The only difference that I see is that I build a new array out of the elements of the SQL recordset array. The contents are identical... Paul Lutus wrote: > gregarican wrote: > > > I am trying to invoke the assoc method on a large array. It seems to > > return nil, although I can verify the elements I am querying against. > > Code? > > -- > Paul Lutus > http://www.arachnoid.com