java类库详细讲解

源代码在线查看: insertarrayps.html

软件大小: 5593 K
上传用户: add505
关键词: java
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				
				
				Inserting a VARRAY Value into an Oracle Table Using a Prepared Statement
				(Java Developers Almanac Example)
				
				
				
				
				
				
								    BODY CODE  {font-family: Courier, Monospace;				           font-size: 11pt}				    TABLE, BODY				          {font-family: Verdana, Arial, Helvetica, sans-serif;				           font-size: 10pt}				    PRE   {font-family: Courier, Monospace;				           font-size: 10pt}				    H3    {font-family: Verdana, Arial, Helvetica, sans-serif;				           font-size: 11pt}				    A.eglink {text-decoration: none}				    A:hover.eglink {text-decoration: underline}				    -->
				
				
				
				
				
				The Java Developers Almanac 1.4
				
				        Order this book from Amazon.
				    
				
				
				
				
				
				
				
				
				
				
				
				Home
				    >
				    List of Packages
				    >
				    java.sql
				         [73 examples]
				        
				        >
				        Oracle VARRAYs
				             [4 examples]
				            
				
				  
				    e303.  
				    Inserting a VARRAY Value into an Oracle Table Using a Prepared Statement
				
				This example inserts a row with a VARRAY of numbers as defined in
				e301 Creating a VARRAY Type in an Oracle Database. This example uses a prepared
				statement.
				
				
				
				    try {
				        // Create an oracle.sql.ARRAY object to hold the values
				        oracle.sql.ArrayDescriptor arrayDesc =
				            oracle.sql.ArrayDescriptor.createDescriptor("number_varray", connection);
				        int arrayValues[] = {123, 234};
				        oracle.sql.ARRAY array = new oracle.sql.ARRAY(arrayDesc, connection, arrayValues);
				    
				        // Create a prepared statement for insertion into varray_table
				        PreparedStatement ps =
				            connection.prepareStatement("INSERT INTO varray_table VALUES(?)");
				    
				        // Set the values to insert
				        ((oracle.jdbc.driver.OraclePreparedStatement)ps).setARRAY(1, array);
				    
				        // Insert the new row
				        ps.execute();
				    } catch (SQLException e) {
				    }
				
				
				
				
				             Related Examples
				        
				
				
				
				
				e301. 
				    Creating a VARRAY Type in an Oracle Database
				
				
				
				e302. 
				    Inserting a VARRAY Value into an Oracle Table
				
				
				
				e304. 
				    Getting a VARRAY Value from an Oracle Table
				
				
				
				
				
				
				
				
				        See also: 
				
				    Batching
				  
				
				
				    Connections
				  
				
				
				    Database Meta Data
				  
				
				
				    Deleting Data
				  
				
				
				    Drivers
				  
				
				
				    Importing and Exporting
				  
				
				
				    Inserting and Updating Data
				  
				
				
				    Oracle OBJECTs
				  
				
				
				    Procedures and Functions
				  
				
				
				    Retrieving Data
				  
				
				
				    Scrollable Result Sets
				  
				
				
				    Tables
				  
				
				
				    Updatable Result Sets
				  
				
				
				
				
				
				
				
				
				
				© 2002 Addison-Wesley.
				
				
				
							

相关资源