2003-02-17 Daniel Morgan <danmorg@sc.rr.com>
[mono.git] / doc / oracle
1 * Oracle Data Provider
2
3 <ul>
4
5         <li>ADO.NET Data Provider for <a href="http://www.oracle.com/">Oracle</a> databases</li>
6
7         <li>Exists in namespace System.Data.OracleClient and assembly System.Data.OracleClient</li>
8
9         <li>Works on Windows and Linux</li>
10
11         <li>Works with Oracle 8i</li>
12
13         <li>Uses the Oracle CLI (Call Level Interface) which is a C library (API) for the Oracle Client 
14                 software</li>
15
16         <li>Internally, the OracleClient provider has OCI abstracted to an object-oriented programming model</li>
17
18         <li>Created by Daniel Morgan and Tim Coleman</li>
19
20         <li>Does not support trusted connections</li>
21
22         <li>Bugs with Mono or the data provider should be reported 
23         in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>.  If you
24         do not have Bugzilla user account, it is free 
25         and easy to 
26         create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
27         
28 </ul>
29         
30 ** Current Status
31
32 <ul>
33         <li>OracleConnection can connect and disconnect to an Oracle 8i database on 
34         Windows and Linux via OCI (Oracle Call-level Interface)</li>
35         
36         <li>No longer uses a glue library (a library between the System.Data.OracleClient.dll
37         assembly and the oci library).  In Current Mono cvs, System.Data.OracleClient 
38         directly platform invokes into the oci library thanks to Tim Coleman.</li>
39         
40         <li>Can have multiple connections with different transactions where each transaction is
41         separated from the others, so a rollback or commit in one transaction 
42         does not affect the other.</li>
43         
44         <li>Can execute simple DML SQL statements, such as, 
45         INSERT a row into the EMP table via the OracleCommand's ExecuteNonQuery method</li>
46                 
47         <li>The System.Data.OracleClient.dll assembly can be built with mcs/mono via
48         the makefile.gnu for System.Data.OracleClient or csc/.net via the
49         System.Data.OracleClient.build nant build file.</li>
50         
51         <li>Can retrieve data via ExecuteReader and OracleDataReader.  Currently, 
52         only simple character
53         data is supported.  ExecuteScalar() still needs to be imlemented.</li>
54                         
55         <li>OracleException and Error handling exists now.</li>
56         
57         <li>Handling of various data types need to be handled</li>
58         
59         <li>Data Adapter needs to be created. Tim has started on it.</li>
60         
61         <li>Lots of missing functionality and bugs.</li>
62         
63         <li>Works with SQL# command-line and GTK# versions in cvs.  Only works with
64         simple character data though.  SQL# For GTK# can only show the results to
65         the TextView because the Data Adapter is not yet available</li>
66            
67 </ul>
68         
69 ** Action Plan
70
71 <ul>
72         <li>Be able to retrieve results via a data reader</li>
73         <li>Parameters support</li>
74         <li>transactions</li>
75         <li>Stored Procedures, Functions, and Packages support</li>
76         <li>Be able to fill a DataTable in a DataSet via a data adapter</li>
77         <li>Support for Oracle 8i and 9i</li>
78         <li>Support LOBs</li>
79         <li>Support all the data types</li>
80         <li>Implement Connection pooling</li>
81         <li>Security</li>
82         
83 </ul>
84
85 ** Testing System.Data.OracleClient
86
87 <ul>
88         <li>Have a working mono and mcs</li>
89         
90         <li>Have access to an Oracle 8i database or download it from
91         <a href="http://www.oracle.com/">Oracle</a>.  If you are connecting
92         remotely to an Oracle database, you need the Oracle client software.
93         Registration to the     Oracle Technology Network is free.  If installing on Linux, 
94         I suggest you do a lot of searching to see how others installed Oracle on Linux.</li>
95         
96         <li>Make sure System.Data.OracleClient.dll assembly is built, if not, go
97         into System.Data.OracleClient and do a make -f makefile.gnu (on Linux) or
98         ../../nant/NAnt.exe (on Windows using Cygwin).</li>
99         
100         <li>Take a look at TestOracleClient.cs found at mcs/class/System.Data.OracleClient/Test</li>
101         
102         <li>The Data Source is an Oracle TNSNAME</li>
103         
104         <li>Has a connection string format:
105 <pre>
106 "Data Source=tnsname;User ID=userid;Password=password"
107 </pre>  
108         </li>
109         <li>C# Example:
110 <pre>
111  using System;
112  using System.Data;
113  using System.Data.OracleClient;
114  
115  public class Test 
116  {
117     public static void Main(string[] args)
118     {
119        string connectionString = 
120           "Data Source=testdb;" +
121           "User ID=scott;" +
122           "Password=tiger;";
123        IDbConnection dbcon;
124        dbcon = new OracleConnection(connectionString);
125        dbcon.Open();
126        IDbCommand dbcmd = dbcon.CreateCommand();
127        string sql = "SELECT ename, job FROM scott.emp";
128        dbcmd.CommandText = sql;
129        IDataReader reader = dbcmd.ExecuteReader();
130        while(reader.Read()) {
131           string employeeName = reader["ename"];
132           string job = reader["job"];
133           Console.WriteLine("Employee Name: {0}  Job: {1}",
134                                     employeeName, job);
135        }
136        // clean up
137        reader.Close();
138        reader = null;
139        dbcmd.CommandText = sql;
140        dbcmd.ExecuteNonQuery();
141        dbcmd.Dispose();
142        dbcmd = null;
143        dbcon.Close();
144        dbcon = null;
145     }
146  }
147 </pre>
148         </li>
149         <li>Building C# Example:
150         <ul>
151                 <li>Save the example to a file, such as, TestExample.cs</li>
152                 <li>Build on Linux:
153 <pre>
154         mcs TestExample.cs -r System.Data.dll \
155             -r System.Data.OracleClient.dll
156 </pre>
157                 </li>
158                 <li>Build on Windows via Cygwin:
159 <pre>
160         mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
161              TestExample.cs \
162              -lib:C:/cygwin/home/MyHome/mono/install/lib \
163              -r System.Data.dll -r System.Data.OracleClient.dll
164 </pre>
165                 </li>
166         </ul>
167         </li>
168         <li>Running the Example:
169 <pre>
170 mono TestExample.exe
171 </pre>
172         </li>
173
174 </ul>
175