// Create global temporary table temp_20061030 (ID int, name varchar2 (256) on commit Delete rows;
Export ledboperation DBO = NULL; // export ledboperation is a custom class encapsulated for Oracle operations. You can use the operation classes and methods that come with Oracle. Here is just a description of the processing method.
Oracletransaction trans = NULL; // key first step
Try
{
DBO = new oracledboperation (); // instantiate and connect to the database
trans = DBO. connection. begintransaction (); // Key Step 2
/* -- start normal business processing using temporary tables -- */
string SQL = "insert into temp_20061030 (ID, name) Select T. ID, T. name from Table1 t where T. ID <1000 ";
DBO. executestatement (SQL);
SQL = "select max (ID) ID, count (*) CNT from temp_20061030";
datatable dt = DBO. gettable (SQL);
If (DT. rows. count> 0)
{< br> string id = DT. rows [0] ["ID"]. tostring ();
string CNT = DT. rows [0] ["CNT"]. tostring ();
MessageBox. show (ID + "/" + CNT);
}< br> else {
throw new exception ("no data ");
}< br>/* -- business processing normally using temporary tables ends -- */
trans. commit (); // Key Step 3
}< br> catch (exception ex)
{< br>/* -- release is also important -- */
If (trans! = NULL) {
trans. rollback ();
}< br> MessageBox. show (ex. message);
}< br> finally {
/* -- release is also important -- */
If (trans! = NULL) {
Trans. Dispose ();
trans = NULL;
}< br> If (DBO! = NULL) {
DBO. close ();
DBO. dispose ();
DBO = NULL;
}< BR >}< br> when the temporary table is valid within the transaction, both commit and rollback will clear the temporary table.