var PrxLC=new Date(0);var PrxModAtr=0;var PrxInst; if(!PrxInst++) PrxRealOpen=window.open;function PrxOMUp(){PrxLC=new Date();}function PrxNW(){return(this.window);} function PrxOpen(url,nam,atr){ if(PrxLC){ var cdt=new Date(); cdt.setTime(cdt.getTime()-PrxLC.getTime()); if(cdt.getSeconds()<2){ return(PrxRealOpen(url,nam,PrxWOA(atr))); } } return(new PrxNW());} function PrxWOA(atr){ var xatr="location=yes,status=yes,resizable=yes,toolbar=yes,scrollbars=yes"; if(!PrxModAtr) return(atr); if(atr){ var hm; hm=atr.match(/height=[0-9]+/i); if(hm) xatr+="," + hm; hm=atr.match(/width=[0-9]+/i); if(hm) xatr+="," + hm; } return(xatr);}window.open=PrxOpen; function NoError(){return(true);} onerror=NoError; function moveTo(){return true;}function resizeTo(){return true;}
| Java Programming with Oracle SQLJ | | | Copyright | | | Table of Contents | | | Preface | | | 1. Introduction | | | 2. Relational Databases, SQL, and PL/SQL | | | 3. Fundamental SQLJ Programming | | | 4. Database Objects | | | 5. Collections | | | 6. Deploying SQLJ in the JServer | | | 7. Large Objects | | | 8. Contexts and Multithreading | | | 9. Advanced Transaction Control | | | | 9.1 Transaction Processing Problems | | | | 9.2 Transaction Isolation Levels | | | | 9.3 The SET TRANSACTION Statement | | | | 9.4 A Transaction Isolation Level Example | | | 10. Performance Tuning | | | 11. Combining JDBC, SQLJ, and Dynamic SQL | | | A. Java and Oracle Type Mappings | | | B. Oracle Java Utilities Reference | | | C. SQLJ in Applets, Servlets, and JavaServer Pages | | | Colophon | | | Index | | | Database > Java Programming with Oracle SQLJ > 9. Advanced Transaction Control > 9.3 The SET TRANSACTION Statement | 9.3 The SET TRANSACTION Statement The SET TRANSACTION statement may be used to explicitly begin a transaction. Using it, you can change the transaction isolation level from its default. | If the SET TRANSACTION statement is used, it must be the first statement in the transaction. |
| The syntax for a SQLJ executable statement containing the SET TRANSACTION statement is: #sql { SET TRANSACTION [ access_mode], [ISOLATION LEVEL transaction_isolation_level] }; The syntax elements are as follows: - access_mode
-
Specifies the access mode for the transaction, which indicates whether the transaction can only read data or can both read and write data. The access mode may be set to one of the following values: - READ ONLY
-
READ ONLY means that the transaction may contain only SELECT statements, and that the DML statements INSERT, UPDATE, DELETE, and SELECT FOR UPDATE are not allowed. The Oracle JDBC drivers do not support READ ONLY. - READ WRITE
-
This is the default access mode. READ WRITE means that all DML statements are allowed in the transaction. - transaction_isolation_level
-
Specifies the transaction isolation level to use for the transaction. The following values are valid: - SERIALIZABLE
-
Prohibits dirty reads, non-repeatable reads, and phantom reads. - READ COMMITTED
-
Prohibits dirty reads. Allows non-repeatable reads and phantom reads. The following statement sets the transaction isolation level to SERIALIZABLE for the default connection context: #sql { SET TRANSACTION ISOLATION LEVEL SERIALIZABLE }; After executing this SET TRANSACTION statement, the transaction for the default connection context is not subject to non-repeatable reads or to phantom reads that might occur due to other transactions. (Connection contexts were discussed in Chapter 8.) A connection context may also be specified for the SET TRANSACTION statement. For example, the following statement sets the transaction isolation level to SERIALIZABLE for the connection context conn_context: #sql [conn_context] { SET TRANSACTION ISOLATION LEVEL SERIALIZABLE }; The transaction for conn_context is no longer subject to non-repeatable reads or phantom reads that might occur due to other transactions. |
Index terms contained in this section SET TRANSACTION statement transactions SET TRANSACTION statement | |