[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

MySQL & Ruby

Marcin Tyman

7/20/2007 1:45:00 PM

Here is my strange issue:

def dump(tableName)
dbh = Mysql.real_connect(SQLServerIP, SQLLogin, SQLPass, SQLDB)
rows = dbh.query("SELECT * FROM #{tableName} r;")

rows.each do |row|
theRow = row.join(" | ")
content << theRow+"\n"
end
.
.
.
puts("None records in #{tableName}!!!") if dbh.affected_rows == 0
dbh.close
end

dumpTable("rm_pre_prov_sta")
dumpTable("rm_active_sta")


First calling return unexpectedly nothing (tabe rm_pre_prov_sta has some
records). Second calling returns some records (as expected).
Command 'select* from rm_pre_prov_sta;' directly from mysql returns some
records. So what is wrong with this all.

Could anyone explain me why dumpTable("rm_pre_prov_sta") returns none of
rows?

--
Posted via http://www.ruby-....

1 Answer

Todd Burch

7/20/2007 11:14:00 PM

0

Marcin Tyman wrote:
> Here is my strange issue:
> ...
> First calling return unexpectedly nothing (tabe rm_pre_prov_sta has some
> records). Second calling returns some records (as expected).
> Command 'select* from rm_pre_prov_sta;' directly from mysql returns some
> records. So what is wrong with this all.
>
> Could anyone explain me why dumpTable("rm_pre_prov_sta") returns none of
> rows?

Perhaps you are getting a non-zero SQLCODE (or SQLSTATE). Have you
checked it?

(DB2 is the database I know - I've never used MySQL. In DB2, you have
to check the SQLCODE)

Todd

--
Posted via http://www.ruby-....