2004-02-18 Gonzalo Paniagua Javier <gonzalo@ximian.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 and 9i.</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>Bugs with Mono or the data provider should be reported 
21         in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>.  If you
22         do not have Bugzilla user account, it is free 
23         and easy to 
24         create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
25         
26 </ul>
27         
28 ** Current Status
29
30 <ul>
31         <li>OracleConnection can connect and disconnect to an Oracle 8i or 9i database on 
32         Windows and Linux via OCI (Oracle Call-level Interface)</li>
33         
34         <li>Can have multiple connections with different transactions where each transaction is
35         separated from the others, so a rollback or commit in one transaction 
36         does not affect the other.</li>
37         
38         <li>Can execute simple DML SQL statements, such as, 
39         INSERT a row into the EMP table via the OracleCommand's ExecuteNonQuery method</li>
40         
41         <li>Can retrieve data via ExecuteReader and OracleDataReader.  Currently, 
42         supports character, numeric, some date data types.  ExecuteScalar
43         also works.</li>
44
45         <li>Simple input parameters (character and numeric data) can now
46         be used in SQL queries.  Output parameters do not yet work.</li>
47                         
48         <li>OracleException and Error handling exists now.</li>
49
50         <li>Message handling needs to be added for non-critical messages
51         received from Oracle</li>
52         
53         <li>Handling of various data types need to be added.</li>
54         
55         <li>Data Adapter exists, and a DataSet can be filled using it.</li>
56         
57         <li>Lots of missing functionality and bugs.</li>
58         
59         <li>Works with SQL# command-line and GTK# GUI versions.</li>
60            
61 </ul>
62         
63 ** Action Plan
64
65 <ul>
66         <li>Be able to retrieve results via a data reader (WORKING)</li>
67         <li>Parameters support (IN PROGRESS)</li>
68         <li>transactions (WORKING)</li>
69         <li>Stored Procedures, Functions, and Packages support</li>
70         <li>Be able to fill a DataTable in a DataSet via a data adapter (IN PROGRESS)</li>
71         <li>Support for Oracle 8i and 9i (WORKING)</li>
72         <li>Support LOBs</li>
73         <li>Support all the data types</li>
74         <li>Implement Connection pooling</li>
75         <li>Security</li>
76         <li>Once Oracle 10g is released, make sure Mono works with Oracle 10g.</li>
77         
78 </ul>
79
80 ** Testing System.Data.OracleClient
81
82 <ul>
83         <li>Have a working mono and mcs</li>
84         
85         <li>Have access to an Oracle 8i or 9i database or download it from
86         <a href="http://www.oracle.com/">Oracle</a>.  If you are connecting
87         remotely to an Oracle database, you need the Oracle client software.
88         Registration to the <a href="http://technet.oracle.com/">Oracle Technology Network</a> is free.  If installing on Linux, 
89         I suggest you do a lot of searching to see how others installed Oracle on Linux.</li>
90         
91         <li>Make sure System.Data.OracleClient.dll assembly is built.</li>
92         
93         <li>Take a look at TestOracleClient.cs found at mcs/class/System.Data.OracleClient/Test</li>
94         
95         <li>The Data Source is an Oracle TNSNAME</li>
96         
97         <li>Has a connection string format:
98 <pre>
99 "Data Source=tnsname;User ID=userid;Password=password"
100 </pre>  
101         </li>
102         <li>C# Example:
103 <pre>
104  using System;
105  using System.Data;
106  using System.Data.OracleClient;
107  
108  public class Test 
109  {
110     public static void Main (string[] args)
111     {
112        string connectionString = 
113           "Data Source=testdb;" +
114           "User ID=scott;" +
115           "Password=tiger;";
116        OracleConnection dbcon = null;
117        dbcon = new OracleConnection (connectionString);
118        dbcon.Open ();
119        OracleCommand dbcmd = dbcon.CreateCommand ();
120        string sql = "SELECT ename, job FROM scott.emp";
121        dbcmd.CommandText = sql;
122        OracleDataReader reader = dbcmd.ExecuteReader ();
123        while (reader.Read ()) {
124           string employeeName = (string) reader["ename"];
125           string job = (string) reader["job"];
126           Console.WriteLine ("Employee Name: {0}  Job: {1}",
127                                     employeeName, job);
128        }
129        // clean up
130        reader.Close ();
131        reader = null;
132        dbcmd.CommandText = sql;
133        dbcmd.ExecuteNonQuery ();
134        dbcmd.Dispose ();
135        dbcmd = null;
136        dbcon.Close ();
137        dbcon = null;
138     }
139  }
140 </pre>
141         </li>
142         <li>Building C# Example:
143         <ul>
144                 <li>Save the example to a file, such as, TestExample.cs</li>
145                 <li>Build on Linux:
146 <pre>
147         mcs TestExample.cs -r System.Data.dll \
148             -r System.Data.OracleClient.dll
149 </pre>
150                 </li>
151                 <li>Build on Windows:
152 <pre>
153         mcs TestExample.cs  /r:System.Data.dll \
154             /r:System.Data.OracleClient.dll
155 </pre>
156                 </li>
157         </ul>
158         </li>
159         <li>Running the Example:
160 <pre>
161 mono TestExample.exe
162 </pre>
163         </li>
164
165 </ul>
166