![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e296. Creating an OBJECT Type in an Oracle DatabaseIn Oracle, you can define a composite data structure called an OBJECT, which consists of one or more basic types. For example, you could define an object calledbook with a title (VARCHAR) and an price
(NUMBER). An OBJECT can also contain other OBJECTs.
This example creates two OBJECT types. The example also creates a table to hold try { // Create a statement Statement stmt = connection.createStatement(); // Create the object2 type stmt.execute("CREATE TYPE object2 AS OBJECT" + "(col_string2 VARCHAR(30), col_integer2 NUMBER)"); // Create the object1 type stmt.execute("CREATE TYPE object1 AS OBJECT" + "(col_string1 VARCHAR(30), col_integer2 object2)"); // Create a table with a column to hold a number and the new object1 type stmt.execute("CREATE TABLE object1_table(col_integer NUMBER, col_object1 object1)"); } catch (SQLException e) { }
e298. Inserting an OBJECT Value into an Oracle Table Using a Prepared Statement e299. Getting an OBJECT Value from an Oracle Table e300. Deleting an OBJECT Type from an Oracle Table © 2002 Addison-Wesley. |