自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Ruby連接到oracle技巧分享

開發(fā) 開發(fā)工具
作為一個剛剛學(xué)習(xí)Ruby語言的朋友來說,對于Ruby連接到oracle的方法技巧還是比較陌生的。希望通過本文的介紹大家可以充分掌握這一技巧應(yīng)用。

Ruby語言作為一種新的開發(fā)編程語言,其具體使用方法還需要我們不斷的去深入了解。在這篇文章中我們將會為大家詳細(xì)介紹有關(guān)Ruby連接到oracle 的一些技巧。#t#

我們可以使用OCI8庫來實現(xiàn)Ruby連接到oracle ,它可以支持oracle8之后的版本:

 

  1. require 'oci8'   
  2. session = OCI8.new('user', 'password')   
  3. query = "SELECT TO_CHAR(SYSDATE, 
    'YYYY/MM/DD') FROM DUAL"   
  4. cursor = session.exec(query)   
  5. result = cursor.fetch       
  6. # Only one iteration inthis case   
  7. cursor.close   
  8. session.logoff 

 

下面是Ruby連接到oracle 查詢的例子:

 

  1. session = OCI8.new("user","password")   
  2. query = "select * from people 
    where name = :name"   
  3. # One way...   
  4. session.exec(query,'John Smith')   
  5. # Another...   
  6. cursor = session.parse(query)   
  7. cursor.exec('John Smith')   
  8. # And another...   
  9. cursor = session.parse(query)   
  10. cursor.bind_param(':name','John Smith')
     # bind by name   
  11. cursor.exec   
  12. # And another.   
  13. cursor = session.parse(query)   
  14. cursor.bind_param(1,'John Smith')   
     # bind by position   
  15. cursor.exec  

以下是Ruby連接到oracle 的代碼示例講解。

責(zé)任編輯:曹凱 來源: ddvip.com
相關(guān)推薦

2009-12-15 18:15:24

Ruby連接到LDAP

2009-12-15 10:23:23

Ruby應(yīng)用技巧

2009-12-18 10:47:16

Ruby裝飾模式

2009-12-18 14:10:29

Ruby訪問剪貼板

2009-12-16 11:04:51

Ruby操作文件權(quán)限

2009-12-17 10:18:17

Ruby創(chuàng)建構(gòu)造器

2009-12-16 10:10:16

Ruby打開關(guān)閉文件

2017-06-13 10:30:20

oracle連接命名

2009-12-16 15:46:41

Ruby on rai

2009-12-16 10:49:42

Ruby操作二進(jìn)制文件

2009-12-17 18:04:59

Ruby調(diào)用Oracl

2009-12-14 09:33:04

Ruby安裝

2009-12-15 18:03:46

Ruby連接數(shù)據(jù)庫

2009-12-16 16:37:59

Ruby on Rai

2009-12-18 17:01:37

Ruby基礎(chǔ)代碼

2009-12-14 18:23:38

Ruby DSL測試

2009-12-14 15:30:43

安裝Ruby on R

2009-12-17 09:49:18

Ruby代碼管理

2009-12-18 17:24:12

Ruby配置Mysql

2009-12-15 14:51:50

Ruby繼承
點贊
收藏

51CTO技術(shù)棧公眾號