Hello, ODP.NET(Boo) World!

Posted on 2月 26th, 2013 by cx20

ODP.NET(Boo)

ODP.NET(Oracle Data Provider for .NET)は、.NET ベースの Oracle Database 接続用 API である。ODAC(Oracle Data Access Component)と呼ばれるパッケージに含まれる。
.NET 環境での Oracle Database 用データプロバイダとしては、マイクロソフト社が提供する「Microsoft Oracle Client」とオラクル社が提供する「ODP.NET」があるが、現在、「Microsoft Oracle Client」はマイクロソフト社自身が非推奨としており、今後は ODP.NET の使用が推奨されている。

データプロバイダ 説明
System.Data.OracleClient .NET Framework Data Provider for Oracle
Oracle.DataAccess.Client Oracle Data Provider for .NET

ソースコード(Boo + ODP.NET + Oracle)

import System
import Oracle.DataAccess.Client
 
[STAThread]
def Main(argv as (string)):
    conStr = "Data Source=ORCL;User ID=scott;Password=tiger"
    sqlStr = "SELECT 'Hello, ODP.NET World!' AS Message FROM DUAL"
 
    con = OracleConnection(conStr)
    cmd = OracleCommand(sqlStr, con)
    con.Open()
 
    reader = cmd.ExecuteReader()
    while reader.Read():
        Console.WriteLine( reader.GetName(0) )
        Console.WriteLine( "---------------------" )
        Console.WriteLine( reader.GetValue(0) )
 
    reader.Close()
    con.Close()

コンパイル方法

C:¥> booc Hello.boo

実行結果

MESSAGE
---------------------
Hello, ODP.NET World!

Tags:

Categories: .NET, Boo, ODP.NET

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

WP-SpamFree by Pole Position Marketing