require 'oci8' #请求OCI8
conn1 = OCI8.new('USERNAME1','PASSWORD1','SERVICE_NAME1') #连接到服务器1
name = conn1.parse("select username from username_table where cd != ' '")
name.exec #执行select语句
while r=name.fetch
puts r #输出username字段
end
conn1.logoff #与服务器1断开连接
conn2 = OCI8.new('USERNAME2','PASSWORD2','SERVICE_NAME2') #连接到服务器2
count = conn2.parse("select count(*) from contactor_table where ownerid in (select id from manager_table where username like '%.....%'))")
count.exec #问题
conn2.logoff #与服务器2断开连接
问题:这里,我想以conn1中查询到的username作为条件进行查询,该如何写呢?因为conn1中返回的结果是username的数组,而在conn2中的select语句又需要作为字符串来查找,'%...%'中不能直接用name.fetch.to_s吧?
最新回复
count = conn2.parse("select count(*) from contactor_table where ownerid in (select id from manager_table where username like '%#{r}%')")
count.exec
end
使用上面的语句后,可以执行了,但是只能返回第一条记录.然后就开始报错
stmt.c:593:in oci8lib.so: ORA-01001: invalid cursor (OCIError)
请问是为什么呢?
是不是并发请求的问题?怎么解决?