13 The Oracle Driver : Data Types

Data Types
Table 13-2 shows how the Oracle data types are mapped to the standard ODBC data types. “Unicode Support” lists Oracle to Unicode data type mappings.
 
Table 13-2. Oracle Data Types 

1
Read-Only

2
Supported only on Oracle 10g and higher.

3
Valid when connecting to Oracle 8 servers; these data types support output parameters to stored procedures

4
Supported only on Oracle 9i and higher.

5
Supported only on Oracle 9i R2 and higher.

The Oracle driver does not support any object types (also known as abstract data types). When the driver encounters an object type during data retrieval, it will return an Unknown Data Type error (SQL State HY000).
See “Retrieving Data Type Information” for more information about data types.
XMLType
Oracle 9i R2 and higher supports the XMLType data type. The Oracle driver supports tables containing columns whose data type is specified as XMLType.
When inserting or updating XMLType columns, the data to be inserted or updated must be in the form of an XMLType data type. The database provides functions to construct XMLType data. The xmlData argument to xmltype( ) may be specified as a string literal.
Example
The following example from the Oracle Web site demonstrates how to create a table, insert data, and retrieve data. Creating a table with XMLType is done the same way as creating a regular table in the Oracle database, using standard SQL syntax:
CREATE TABLE PURCHASEORDER (PODOCUMENT sys.XMLTYPE);
The PURCHASEORDER table contains one column—PODOCUMENT—with a data type of XMLType (sys.XMLTYPE). The next step is to insert one purchase order, created by the static function sys.XMLTYPE.createXML:
INSERT INTO PURCHASEORDER (PODOCUMENT) values (
sys.XMLTYPE.createXML(
'
<PurchaseOrder>
<Reference>BLAKE-2001062514034298PDT</Reference>
 
<Actions>
<Action>
<User>KING</User>
<Date/>
</Action>
</Actions>
<Reject/>
 
<Requester>David E. Blake</Requester>
<User>BLAKE</User>
<CostCenter>S30</CostCenter>
<ShippingInstructions>
<name>David E. Blake</name>
<address>400 Oracle Parkway Redwood Shores, CA, 94065 USA</address>
<telephone>650 999 9999</telephone>
</ShippingInstructions>
 
<SpecialInstructions>Air Mail</SpecialInstructions>
<LineItems>
<LineItem ItemNumber="1">
<Description>The Birth of a Nation</Description>
<Part Id="EE888" UnitPrice="65.39" Quantity="31"/>
</LineItem>
</LineItems>
</PurchaseOrder>
'));
Use the getClobVal function to retrieve the data:
SELECT p.podocument.getClobVal() FROM PURCHASEORDER p;