How would I go about connecting to oracle from F#? Is there a drive or can I load up the C# driver? I'm very new to F#.
+4
A:
You can use the same libraries as you use in C# - .NET interoperability is one of the key features of F#. There are some classes in the Base Class Library which you could use (in System.Data.Oracle.dll), but these have been deprecated in favor of Oracle's own .NET drivers (Oracle Data Provider for .NET).
F# code using ODP.NET might look something like:
#if INTERACTIVE
#r "System.Data"
#r "Oracle.DataAccess"
#endif
open System.Data
open Oracle.DataAccess.Client
let conn = OracleConnection("User Id=scott;Password=tiger;Data Source=oracle")
conn.Open()
let cmd = conn.CreateCommand()
cmd.CommandText = "select * from emp"
let rdr = reader = cmd.ExecuteReader()
let empIds =
[while reader.Read() do
yield reader.GetInt32(0)]
kvb
2010-08-14 01:51:43