Ruby语言作为一种新的开发编程语言,其具体使用方法还需要我们不断的去深入了解。在这篇文章中我们将会为大家详细介绍有关Ruby连接到oracle 的一些技巧。#t#
我们可以使用OCI8库来实现Ruby连接到oracle ,它可以支持oracle8之后的版本:
下面是Ruby连接到oracle 查询的例子:
- session = OCI8.new("user","password")
- query = "select * from people
where name = :name"- # One way...
- session.exec(query,'John Smith')
- # Another...
- cursor = session.parse(query)
- cursor.exec('John Smith')
- # And another...
- cursor = session.parse(query)
- cursor.bind_param(':name','John Smith')
# bind by name- cursor.exec
- # And another.
- cursor = session.parse(query)
- cursor.bind_param(1,'John Smith')
# bind by position- cursor.exec
以下是Ruby连接到oracle 的代码示例讲解。
上一篇:全面接触华为无线路由设置图解