10.12.2012 Views

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Describing Database Metadata<br />

You obtain metadata by calling the getMetaData method on the Connection<br />

class in case of an explicit describe, or by calling the getColumnListMetaData<br />

method on the ResultSet class to get the metadata of the result set columns. Both<br />

methods return a MetaData object with the described information. The MetaData<br />

class provides the getxxx methods to access this information.<br />

Notes on Types and Attributes<br />

When performing DESCRIBE operations, be aware of the following issues:<br />

■ The ATTR_TYPECODE returns typecodes that represent the type supplied when<br />

you created a new type by using the CREATE TYPE statement. These typecodes<br />

are of the enumerated type OCCITypeCode, which are represented by OCCI_<br />

TYPECODE constants.<br />

■ The ATTR_DATA_TYPE returns types that represent the datatypes of the<br />

database columns. These values are of enumerated type OCCIType. For<br />

example, LONG types return OCCI_SQLT_LNG types.<br />

Describing Database Metadata<br />

Note: Internal PL/SQL types (boolean, indexed table) are not<br />

supported.<br />

Describing database metadata is equivalent to an explicit DESCRIBE operation. The<br />

object to describe must be an object in the schema. In describing a type, you call the<br />

getMetaData method from the connection, passing the name of the object or a<br />

RefAny object. To do this, you must initialize the environment in the OBJECT<br />

mode. The getMetaData method returns an object of type MetaData. Each type of<br />

MetaData object has a list of attributes that are part of the describe tree. The<br />

describe tree can then be traversed recursively to point to subtrees containing more<br />

information. More information about an object can be obtained by calling the<br />

getxxx methods.<br />

If you need to construct a browser that describes the database and its objects<br />

recursively, then you can access information regarding the number of attributes for<br />

each object in the database (including the database), the attribute ID listing, and the<br />

attribute types listing. By using this information, you can recursively traverse the<br />

describe tree from the top node (the database) to the columns in the tables, the<br />

attributes of a type, the parameters of a procedure or function, and so on.<br />

Metadata 6-3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!