Skip Headers
Oracle® C++ Call Interface Programmer's Guide,
11g Release 1 (11.1)

Part Number B28390-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

6 Metadata

This chapter describes how to retrieve metadata about result sets or the database as a whole.

This chapter contains these topics:

Overview of Metadata

Database objects have various attributes that describe them; you can obtain information about a particular schema object by performing a DESCRIBE operation. The result can be accessed as an object of the Metadata class by passing object attributes as arguments to the various methods of the Metadata class.

You can perform an explicit DESCRIBE operation on the database as a whole, on the types and properties of the columns contained in a ResultSet class, or on any of the following schema and subschema objects, such as tables, types, sequences, views, type attributes, columns, procedures, type methods, arguments, functions, collections, results, packages, synonyms, and lists

You must specify the type of the attribute you are looking for. By using the getAttributeCount(), getAttributeId(), and getAttributeType() methods of the MetaData class, you can scan through each available attribute.

All DESCRIBE information is cached until the last reference to it is deleted. Users are in this way prevented from accidentally trying to access DESCRIBE information that is already freed.

You obtain metadata by calling the getMetaData() method on the Connection class in case of an explicit describe, or by calling the getColumnListMetaData() method on the ResultSet class to get the metadata of the result set columns. Both methods return a MetaData object with the describing information. The MetaData class provides the getxxx() methods to access this information.

Notes on Types and Attributes

When performing DESCRIBE operations, be aware of the following issues:

  • The ATTR_TYPECODE returns type codes that represent the type supplied when you created a new type by using the CREATE TYPE statement. These type codes are of the enumerated type TypeCode, which are represented by OCCI_TYPECODE constants.

    Note:

    Internal PL/SQL types (boolean, indexed table) are not supported.
  • The ATTR_DATA_TYPE returns types that represent the datatypes of the database columns. These values are of enumerated type Type. For example, LONG types return OCCI_SQLT_LNG types.

Describing Database Metadata

Describing database metadata is equivalent to an explicit DESCRIBE operation. The object to describe must be an object in the schema. In describing a type, you call the getMetaData() method from the connection, passing the name of the object or a RefAny object. To do this, you must initialize the environment in the OBJECT mode. The getMetaData() method returns an object of type MetaData. Each type of MetaData object has a list of attributes that are part of the describe tree. The describe tree can then be traversed recursively to point to subtrees that contain more information. More information about an object can be obtained by calling the getxxx() methods.

If you need to construct a browser that describes the database and its objects recursively, then you can access information regarding the number of attributes for each object in the database (including the database), the attribute ID listing, and the attribute types listing. By using this information, you can recursively traverse the describe tree from the top node (the database) to the columns in the tables, the attributes of a type, the parameters of a procedure or function, and so on.

For example, consider the typical case of describing a table and its contents. You call the getMetaData() method from the connection, passing the name of the table to be described. The MetaData object returned contains the table information. Since you are aware of the type of the object that you want to describe (table, column, type, collection, function, procedure, and so on), you can obtain the attribute list. You can retrieve the value into a variable of the type specified in the table by calling the corresponding getxxx() method.

Metadata Code Examples

This section provides code examples for using metadata:

Example 6-1 How to Obtain Metadata About Attributes of a Simple Database Table

This example demonstrates how to obtain metadata about attributes of a simple database table:

/* Create an environment and a connection to the HR database */
.
.
/* Call the getMetaData method on the Connection object obtainedv*/
MetaData emptab_metaData = connection->getMetaData(
      "EMPLOYEES", MetaData::PTYPE_TABLE);
/* Now that you have the metadata information on the EMPLOYEES table,
   call the getxxx methods using the appropriate attributes */

/* Call getString */
cout<<"Schema:"<<
              (emptab_metaData.getString(MetaData::ATTR_OBJ_SCHEMA))<<endl;

if(emptab_metaData.getInt(
              emptab_metaData::ATTR_PTYPE)==MetaData::PTYPE_TABLE)
   cout<<"EMPLOYEES is a table"<<endl;
else
    cout<<"EMPLOYEES is not a table"<<endl;

/* Call getInt to get the number of columns in the table */
int columnCount=emptab_metaData.getInt(MetaData::ATTR_NUM_COLS);
cout<<"Number of Columns:"<<columnCount<<endl;

/* Call getTimestamp to get the timestamp of the table object */
Timestamp tstamp = emptab_metaData.getTimestamp(MetaData::ATTR_TIMESTAMP);
/* Now that you have the value of the attribute as a Timestamp object,
   you can call methods to obtain the components of the timestamp */
int year;
unsigned int month, day;
tstamp.getData(year, month, day);

/* Call getVector for attributes of list type, e.g. ATTR_LIST_COLUMNS */
vector<MetaData>listOfColumns;
listOfColumns=emptab_metaData.getVector(MetaData::ATTR_LIST_COLUMNS);

/* Each of the list elements represents a column metadata,
   so now you can access the column attributes*/
for (int i=0;i<listOfColumns.size();i++
{
   MetaData columnObj=listOfColumns[i];
   cout<<"Column Name:"<<(columnObj.getString(MetaData::ATTR_NAME))<<endl;
   cout<<"Data Type:"<<(columnObj.getInt(MetaData::ATTR_DATA_TYPE))<<endl;
   .
   .
   /* and so on to obtain metadata on other column specific attributes */
}

Example 6-2 How to Obtain Metadata from a Column Containing User-Defined Types

This example demonstrates how to obtain metadata from a column that contains user-defined types database table.

/* Create an environment and a connection to the HR database */
...
/* Call the getMetaData method on the Connection object obtained */
MetaData custtab_metaData = connection->getMetaData(
      "CUSTOMERS", MetaData::PTYPE_TABLE);

/* Have metadata information on CUSTOMERS table; call the getxxx methods */
/* Call getString */
cout<<"Schema:"<<(custtab_metaData.getString(MetaData::ATTR_OBJ_SCHEMA))
     <<endl;
if(custtab_metaData.getInt(custtab_metaData::ATTR_PTYPE)==MetaData::PTYPE_TABLE)
   cout<<"CUSTOMERS is a table"<<endl;
else
   cout<<"CUSTOMERS is not a table"<<endl;

/* Call getVector to obtain list of columns in the CUSTOMERS table */
vector<MetaData>listOfColumns;
listOfColumns=custtab_metaData.getVector(MetaData::ATTR_LIST_COLUMNS);

/* Assuming metadata for column cust_address_typ is fourth element in list*/
MetaData customer_address=listOfColumns[3];

/* Obtain the metadata for the customer_address attribute */
int typcode = customer_address.getInt(MetaData::ATTR_TYPECODE);
if(typcode==OCCI_TYPECODE_OBJECT)
   cout<<"customer_address is an object type"<<endl;
else
   cout<<"customer_address is not an object type"<<endl;

string objectName=customer_address.getString(MetaData::ATTR_OBJ_NAME);

/* Now that you have the name of the address object,
   the metadata of the attributes of the type can be obtained by using
   getMetaData on the connection by passing the object name
*/
MetaData address = connection->getMetaData(objectName);

/* Call getVector to obtain the list of the address object attributes */
vector<MetaData> attributeList = 
      address.getVector(MetaData::ATT_LIST_TYPE_ATTRS);

/* and so on to obtain metadata on other address object specific attributes */

Example 6-3 How to Obtain Object Metadata from a Reference

This example demonstrates how to obtain metadata about an object when using a reference to it:

Type ADDRESS(street VARCHAR2(50), city VARCHAR2(20));
Table Person(id NUMBER, addr REF ADDRESS);

/* Create an environment and a connection to the HR database */
.
.
/* Call the getMetaData method on the Connection object obtained */
MetaData perstab_metaData = connection->getMetaData(
      "Person", MetaData::PTYPE_TABLE);

/* Now that you have the metadata information on the Person table,
   call the getxxx methods using the appropriate attributes */
/* Call getString */
cout<<"Schema:"<<(perstab_metaData.getString(MetaData::ATTR_OBJ_SCHEMA))<<endl;

if(perstab_metaData.getInt(perstab_metaData::ATTR_PTYPE)==MetaData::PTYPE_TABLE)
   cout<<"Person is a table"<<endl;
else
   cout<<"Person is not a table"<<endl;

/* Call getVector to obtain the list of columns in the Person table*/
vector<MetaData>listOfColumns;
listOfColumns=perstab_metaData.getVector(MetaData::ATTR_LIST_COLUMNS);

/* Each of the list elements represents a column metadata,
   so now get the datatype of the column by passing ATTR_DATA_TYPE
   to getInt */
for(int i=0;i<numCols;i++)
{
   int dataType=colList[i].getInt(MetaData::ATTR_DATA_TYPE);
   /* If the datatype is a reference, get the Ref and obtain the metadata
      about the object by passing the Ref to getMetaData */
   if(dataType==SQLT_REF)
      RefAny refTdo=colList[i].getRef(MetaData::ATTR_REF_TDO);

   /* Now you can obtain the metadata about the object as shown
   MetaData tdo_metaData=connection->getMetaData(refTdo);

   /* Now that you have the metadata about the TDO, you can obtain the metadata
      about the object */
}

Example 6-4 How to Obtain Metadata About a Select List from a ResultSet Object

This example demonstrates how to obtain metadata about a select list from a ResultSet.

/* Create an environment and a connection to the database */
...
/* Create a statement and associate it with a select clause */
string sqlStmt="SELECT * FROM EMPLOYEES";
Statement *stmt=conn->createStatement(sqlStmt);

/* Execute the statement to obtain a ResultSet */
ResultSet *rset=stmt->executeQuery();

/* Obtain the metadata about the select list */
vector<MetaData>cmd=rset->getColumnListMetaData();

/* The metadata is a column list and each element is a column metaData */
int dataType=cmd[i].getInt(MetaData::ATTR_DATA_TYPE);
...

The getMetaData method is called for the ATTR_COLLECTION_ELEMENT attribute only.

Attribute Reference

This section describes the attributes belonging to schema and subschema objects.

Parameter Attributes

All elements have some attributes specific to that element and some generic attributes. Table 6-1 describes the attributes that belong to all elements:

Table 6-1 Attributes that Belong to All Elements

Attribute Description Attribute Datatype

ATTR_OBJ_ID

Object or schema ID

unsigned int

ATTR_OBJ_NAME

Object, schema, or database name

string

ATTR_OBJ_SCHEMA

Schema where object is located

string

ATTR_OBJ_PTYPE

Type of information described by the parameter. Possible values are:

PTYPE_TABLE, Table

PTYPE_VIEW, View

PTYPE_PROC, Procedure

PTYPE_FUNC, Function

PTYPE_PKG, Package

PTYPE_TYPE, Type

PTYPE_TYPE_ATTR, Attribute of a type

PTYPE_TYPE_COLL, Collection type information

PTYPE_TYPE_METHOD, A method of a type

PTYPE_SYN, Synonym

PTYPE_SEQ, Sequence

PTYPE_COL, Column of a table or view

PTYPE_ARG, Argument of a function or procedure

PTYPE_TYPE_ARG, Argument of a type method

PTYPE_TYPE_RESULT, Results of a method

PTYPE_SCHEMA, Schema

PTYPE_DATABASE, Database

int

ATTR_TIMESTAMP

The TIMESTAMP of the object this description is based on (Oracle DATE format).

Timestamp


The sections that follow list attributes specific to different types of elements.

Table and View Attributes

A parameter for a table or view (type PTYPE_TABLE or PTYPE_VIEW) has the following type-specific attributes described in Table 6-2:

Table 6-2 Attributes that Belong to Tables or Views

Attribute Description Attribute Datatype

ATTR_OBJID

Object ID

unsigned int

ATTR_NUM_COLS

Number of columns

int

ATTR_LIST_COLUMNS

Column list (type PTYPE_LIST)

vector<MetaData>

ATTR_REF_TDO

REF to the object type that is being described

RefAny

ATTR_IS_TEMPORARY

Identifies whether the table or view is temporary

bool

ATTR_IS_TYPED

Identifies whether the table or view is typed

bool

ATTR_DURATION

Duration of a temporary table. Values can be:

  • DURATION_SESSION (session)

  • DURATION_TRANS (transaction)

  • DURATION_NULL (table not temporary)

int


The additional attributes belonging to tables are described in Table 6-3.

Table 6-3 Attributes Specific to Tables

Attribute Description Attribute Datatype

ATTR_DBA

Data block address of the segment header

unsigned int

ATTR_TABLESPACE

Tablespace the table resides on

int

ATTR_CLUSTERED

Identifies whether the table is clustered

bool

ATTR_PARTITIONED

Identifies whether the table is partitioned

bool

ATTR_INDEX_ONLY

Identifies whether the table is index only

bool


Procedure, Function, and Subprogram Attributes

A parameter for a procedure or function (type PTYPE_PROC or PTYPE_FUNC) has the type-specific attributes described in Table 6-4.

Table 6-4 Attributes that Belong to Procedures or Functions

Attribute Description Attribute Datatype

ATTR_LIST_ARGUMENTS

Argument list; refer to List Attributes .

vector<MetaData>

ATTR_IS_INVOKER_RIGHTS

Identifies whether the procedure or function has invoker's rights.

int


The additional attributes belonging to package subprograms are described in Table 6-5.

Table 6-5 Attributes that Belong to Package Subprograms

Attribute Description Attribute Datatype

ATTR_NAME

Name of procedure or function

string

ATTR_OVERLOAD_ID

Overloading ID number (relevant in case the procedure or function is part of a package and is overloaded). Values returned may be different from direct query of a PL/SQL function or procedure.

int


Package Attributes

A parameter for a package (type PTYPE_PKG) has the type-specific attributes described in Table 6-6.

Table 6-6 Attributes that Belong to Packages

Attribute Description Attribute Datatype

ATTR_LIST_SUBPROGRAMS

Subprogram list; refer to List Attributes.

vector<MetaData>

ATTR_IS_INVOKER_RIGHTS

Identifies whether the package has invoker's rights

bool


Type Attributes

A parameter for a type (type PTYPE_TYPE) has attributes described in Table 6-7.

Table 6-7 Attributes that Belong to Types

Attribute Description Attribute Datatype

ATTR_REF_TDO

Returns the in-memory ref of the type descriptor object for the type, if the column type is an object type.

RefAny

ATTR_TYPECODE

Type code. Can be:

  • OCCI_TYPECODE_OBJECT

  • OCCI_TYPECODE_NAMEDCOLLECTION

Refer to Notes on Types and Attributes.

int

ATTR_COLLECTION_TYPECODE

Type code of collection if type is collection; invalid otherwise. Can be:

  • OCCI_TYPECODE_VARRAY

  • OCCI_TYPECODE_TABLE

Refer to Notes on Types and Attributes.

int

ATTR_VERSION

A NULL-terminated string containing the user-assigned version

string

ATTR_IS_FINAL_TYPE

Identifies whether this is a final type

bool

ATTR_IS_INSTANTIABLE_TYPE

Identifies whether this is an instantiable type

bool

ATTR_IS_SUBTYPE

Identifies whether this is a subtype

bool

ATTR_SUPERTYPE_SCHEMA_NAME

Name of the schema containing the supertype

string

ATTR_SUPERTYPE_NAME

Name of the supertype

string

ATTR_IS_INVOKER_RIGHTS

Identifies whether this type is invoker's rights

bool

ATTR_IS_INCOMPLETE_TYPE

Identifies whether this type is incomplete

bool

ATTR_IS_SYSTEM_TYPE

Identifies whether this is a system type

bool

ATTR_IS_PREDEFINED_TYPE

Identifies whether this is a predefined type

bool

ATTR_IS_TRANSIENT_TYPE

Identifies whether this is a transient type

bool

ATTR_IS_SYSTEM_GENERATED_TYPE

Identifies whether this is a system-generated type

bool

ATTR_HAS_NESTED_TABLE

Identifies whether this type contains a nested table attribute

bool

ATTR_HAS_LOB

Identifies whether this type contains a LOB attribute

bool

ATTR_HAS_FILE

Identifies whether this type contains a FILE attribute

bool

ATTR_COLLECTION_ELEMENT

Handle to collection element

Refer to Collection Attributes

MetaData

ATTR_NUM_TYPE_ATTRS

Number of type attributes

unsigned int

ATTR_LIST_TYPE_ATTRS

List of type attributes

Refer to List Attributes

vector<MetaData>

ATTR_NUM_TYPE_METHODS

Number of type methods

unsigned int

ATTR_LIST_TYPE_METHODS

List of type methods

Refer to List Attributes

vector<MetaData>

ATTR_MAP_METHOD

Map method of type

Refer to Type Method Attributes

MetaData

ATTR_ORDER_METHOD

Order method of type; refer to Type Method Attributes

MetaData


Type Attribute Attributes

A parameter for an attribute of a type (type PTYPE_TYPE_ATTR) has the attributes described in Table 6-8.

Table 6-8 Attributes that Belong to Type Attributes

Attribute Description Attribute Datatype

ATTR_DATA_SIZE

Maximum size of the type attribute. This length is returned in bytes and not characters for strings and raws. Returns 22 for NUMBER.

int

ATTR_TYPECODE

Type code

Refer to Notes on Types and Attributes.

int

ATTR_DATA_TYPE

Datatype of the type attribute

Refer to Notes on Types and Attributes.

int

ATTR_NAME

A pointer to a string that is the type attribute name

string

ATTR_PRECISION

Precision of numeric type attributes. If the precision is nonzero and scale is -127, then it is a FLOAT; otherwise a NUMBER(p, s). If precision is 0, then NUMBER(p, s) can be represented simply by NUMBER.

int

ATTR_SCALE

Scale of numeric type attributes. If the precision is nonzero and scale is -127, then it is a FLOAT; otherwise a NUMBER(p, s). If precision is 0, then NUMBER(p, s) can be represented simply as NUMBER.

int

ATTR_TYPE_NAME

A string that is the type name. The returned value will contain the type name if the datatype is SQLT_NTY or SQLT_REF. If the datatype is SQLT_NTY, then the name of the named datatype's type is returned. If the datatype is SQLT_REF, then the type name of the named datatype pointed to by the REF is returned.

string

ATTR_SCHEMA_NAME

String with the schema name under which the type has been created

string

ATTR_REF_TDO

Returns the in-memory REF of the TDO for the type, if the column type is an object type.

RefAny

ATTR_CHARSET_ID

Character set ID, if the type attribute is of a string or character type

int

ATTR_CHARSET_FORM

Character set form, if the type attribute is of a string or character type

int

ATTR_FSPRECISION

The fractional seconds precision of a datetime or interval

int

ATTR_LFPRECISION

The leading field precision of an interval

int


Type Method Attributes

A parameter for a method of a type (type PTYPE_TYPE_METHOD) has the attributes described in Table 6-9.

Table 6-9 Attributes that Belong to Type Methods

Attribute Description Attribute Datatype

ATTR_NAME

Name of method (procedure or function)

string

ATTR_ENCAPSULATION

Encapsulation level of the method; can be:

  • OCCI_TYPEENCAP_PRIVATE

  • OCCI_TYPEENCAP_PUBLIC)

int

ATTR_LIST_ARGUMENTS

Argument list

vector<MetaData>

ATTR_IS_CONSTRUCTOR

Identifies whether the method is a constructor

bool

ATTR_IS_DESTRUCTOR

Identifies whether the method is a destructor

bool

ATTR_IS_OPERATOR

Identifies whether the method is an operator

bool

ATTR_IS_SELFISH

Identifies whether the method is selfish

bool

ATTR_IS_MAP

Identifies whether the method is a map method

bool

ATTR_IS_ORDER

Identifies whether the method is an order method

bool

ATTR_IS_RNDS

Identifies whether "Read No Data State" is set for the method

bool

ATTR_IS_RNPS

Identifies whether "Read No Process State" is set for the method

bool

ATTR_IS_WNDS

Identifies whether "Write No Data State" is set for the method

bool

ATTR_IS_WNPS

Identifies whether "Write No Process State" is set for the method

bool

ATTR_IS_FINAL_METHOD

Identifies whether this is a final method

bool

ATTR_IS_INSTANTIABLE_METHOD

Identifies whether this is an instantiable method

bool

ATTR_IS_OVERRIDING_METHOD

Identifies whether this is an overriding method

bool


Collection Attributes

A parameter for a collection type (type PTYPE_COLL) has the attributes described in Table 6-10.

Table 6-10 Attributes that Belong to Collection Types

Attribute Description Attribute Datatype

ATTR_DATA_SIZE

Maximum size of the type attribute. This length is returned in bytes and not characters for strings and raws. Returns 22 for NUMBER.

int

ATTR_TYPECODE

Typecode; refer to Notes on Types and Attributes.

int

ATTR_DATA_TYPE

The datatype of the type attribute; refer to Notes on Types and Attributes.

int

ATTR_NUM_ELEMENTS

Number of elements in an array; only valid for collections that are arrays.

unsigned int

ATTR_NAME

A pointer to a string that is the type attribute name

string

ATTR_PRECISION

Precision of numeric type attributes. If the precision is nonzero and scale is -127, then it is a FLOAT; otherwise a NUMBER(p, s). If precision is 0, then NUMBER(p, s) can be represented simply as NUMBER.

int

ATTR_SCALE

Scale of numeric type attributes. If the precision is nonzero and scale is -127, then it is a FLOAT; otherwise a NUMBER(p, s). If precision is 0, then NUMBER(p, s) can be represented simply as NUMBER.

int

ATTR_TYPE_NAME

String that is the type name. The returned value will contain the type name if the datatype is SQLT_NTY or SQLT_REF. If the datatype is SQLT_NTY, then the name of the named datatype's type is returned. If the datatype is SQLT_REF, then the type name of the named datatype pointed to by the REF is returned

string

ATTR_SCHEMA_NAME

String with the schema name under which the type has been created

string

ATTR_REF_TDO

Returns the in memory REF of the TDO for the type.

RefAny

ATTR_CHARSET_ID

Typecode; refer to Notes on Types and Attributes.

int

ATTR_CHARSET_FORM

The datatype of the type attribute; refer to Notes on Types and Attributes.

int


Synonym Attributes

A parameter for a synonym (type PTYPE_SYN) has the attributes described in Table 6-11.

Table 6-11 Attributes that Belong to Synonyms

Attribute Description Attribute Datatype

ATTR_OBJID

Object ID

unsigned int

ATTR_SCHEMA_NAME

Null-terminated string containing the schema name of the synonym translation

string

ATTR_NAME

Null-terminated string containing the object name of the synonym translation

string

ATTR_LINK

Null-terminated string containing the database link name of the synonym translation

string


Sequence Attributes

A parameter for a sequence (type PTYPE_SEQ) has the attributes described in Table 6-12.

Table 6-12 Attributes that Belong to Sequences

Attribute Description Attribute Datatype

ATTR_OBJID

Object ID

unsigned int

ATTR_MIN

Minimum value (in Oracle number format)

Number

ATTR_MAX

Maximum value (in Oracle number format)

Number

ATTR_INCR

Increment (in Oracle number format)

Number

ATTR_CACHE

Number of sequence numbers cached; zero if the sequence is not a cached sequence (in Oracle number format)

Number

ATTR_ORDER

Identifies whether the sequence is ordered

bool

ATTR_HW_MARK

High-water mark (in Oracle number format)

Number


Column Attributes

A parameter for a column of a table or view (type PTYPE_COL) has the attributes described in Table 6-13.

Table 6-13 Attributes that Belong to Columns of Tables or Views

Attribute Description Attribute Datatype

ATTR_DATA_SIZE

Column length in codepoints. The number of codepoints allowed in the column.

int

ATTR_DATA_TYPE

Type of length semantics of the column. Valid values are 0 for byte-length semantics and 1 for codepoint-length semantics.

int

ATTR_NAME

Maximum size of the column. This length is returned in bytes and not characters for strings and raws. Returns 22 for NUMBER.

string

ATTR_PRECISION

The datatype of the column; refer to Notes on Types and Attributes.

int

ATTR_SCALE

Pointer to a string that is the column name

int

ATTR_IS_NULL

Returns TRUE if the attribute is NULL; FALSE otherwise.

bool

ATTR_TYPE_NAME

Scale of numeric columns. If the precision is nonzero and scale is -127, then it is a FLOAT; otherwise a NUMBER(p, s). If precision is 0, then NUMBER(p, s) can be represented simply as NUMBER.

string

ATTR_SCHEMA_NAME

Returns 0 if null values are not permitted for the column

string

ATTR_REF_TDO

Returns a string that is the type name. The returned value will contain the type name if the datatype is SQLT_NTY or SQLT_REF. If the datatype is SQLT_NTY, then the name of the named datatype's type is returned. If the datatype is SQLT_REF, then the type name of the named datatype pointed to by the REF is returned.

RefAny

ATTR_CHARSET_ID

Returns a string with the schema name under which the type has been created.

int

ATTR_CHARSET_FORM

The REF of the TDO for the type, if the column type is an object type

int


Argument and Result Attributes

A parameter for an argument or a procedure or function type (type PTYPE_ARG), for a type method argument (type PTYPE_TYPE_ARG), or for method results (type PTYPE_TYPE_RESULT) has the attributes described in Table 6-14.

Table 6-14 Attributes that Belong to Arguments / Results

Attribute Description Attribute Datatype

ATTR_NAME

Returns a pointer to a string which is the argument name

string

ATTR_POSITION

Position of the argument in the argument list. Always returns 0.

int

ATTR_TYPECODE

Typecode; refer to Notes on Types and Attributes.

int

ATTR_DATA_TYPE

Datatype of the argument; refer to Notes on Types and Attributes.

int

ATTR_DATA_SIZE

Size of the datatype of the argument. This length is returned in bytes and not characters for strings and raws. Returns 22 for NUMBER.

int

ATTR_PRECISION

Precision of numeric arguments. If the precision is nonzero and scale is -127, then it is a FLOAT; otherwise a NUMBER(p, s). If precision is 0, then NUMBER(p, s) can be represented simply as NUMBER.

int

ATTR_SCALE

Scale of numeric arguments. If the precision is nonzero and scale is -127, then it is a FLOAT; otherwise a NUMBER(p, s). If precision is 0, then NUMBER(p, s) can be represented simply as NUMBER.

int

ATTR_LEVEL

Datatype levels. This attribute always returns 0.

int

ATTR_HAS_DEFAULT

Indicates whether an argument has a default

int

ATTR_LIST_ARGUMENTS

The list of arguments at the next level (when the argument is of a record or table type)

vector<MetaData>

ATTR_IOMODE

Indicates the argument mode; valid values are:

  • 0 for IN (OCCI_TYPEPARAM_IN)

  • 1 for OUT (OCCI_TYPEPARAM_OUT)

  • 2 for IN/OUT (OCCI_TYPEPARAM_INOUT)

int

ATTR_RADIX

Returns a radix (if number type)

int

ATTR_IS_NULL

Returns FALSE if NULL values are not permitted for the column.

bool

ATTR_TYPE_NAME

Returns a string that is the type name, or the package name in the case of package local types. The returned value contains the type name if the datatype is SQLT_NTY or SQLT_REF. If the datatype is SQLT_NTY, then the name of the named datatype's type is returned. If the datatype is SQLT_REF, then the type name of the named datatype pointed to by the REF is returned.

string

ATTR_SCHEMA_NAME

For SQLT_NTY or SQLT_REF, returns a string with the schema name under which the type was created, or under which the package was created in the case of package local types

string

ATTR_SUB_NAME

For SQLT_NTY or SQLT_REF, returns a string with the type name, in the case of package local types

string

ATTR_LINK

For SQLT_NTY or SQLT_REF, returns a string with the database link name of the database on which the type exists. This can happen only in the case of package local types, when the package is remote.

string

ATTR_REF_TDO

Returns the REF of the TDO for the type, if the argument type is an object

RefAny

ATTR_CHARSET_ID

Returns the character set ID if the argument is of a string or character type

int

ATTR_CHARSET_FORM

Returns the character set form if the argument is of a string or character type

int


List Attributes

A list type of attribute can be described for all the elements in the list. In case of a function argument list, position 0 has a parameter for return values (PTYPE_ARG).

The list is described iteratively for all the elements. The results are stored in a C++ vector<MetaData>. Call the getVector() method to describe list type of attributes. Table 6-15 displays the list attributes.

Table 6-15 Values for ATTR_LIST_TYPE

Possible Values Description

ATTR_LIST_COLUMNS

Column list

ATTR_LIST_ARGUMENTS

Procedure or function arguments list

ATTR_LIST_SUBPROGRAMS

Subprogram list

ATTR_LIST_TYPE_ATTRIBUTES

Type attribute list

ATTR_LIST_TYPE_METHODS

Type method list

ATTR_LIST_OBJECTS

Object list within a schema

ATTR_LIST_SCHEMAS

Schema list within a database


Schema Attributes

A parameter for a schema type (type PTYPE_SCHEMA) has the attributes described in Table 6-16.

Table 6-16 Attributes Specific to Schemas

Attribute Description Attribute Datatype

ATTR_LIST_OBJECTS

List of objects in the schema

string


Database Attributes

A parameter for a database (type PTYPE_DATABASE) has the attributes described in Table 6-17.

Table 6-17 Attributes Specific to Databases

Attribute Description Attribute Datatype

ATTR_VERSION

Database version

string

ATTR_CHARSET_ID

Database character set ID from the server handle

int

ATTR_NCHARSET_ID

Database native character set ID from the server handle

int

ATTR_LIST_SCHEMAS

List of schemas (type PTYPE_SCHEMA) in the database

vector<MetaData>

ATTR_MAX_PROC_LEN

Maximum length of a procedure name

unsigned int

ATTR_MAX_COLUMN_LEN

Maximum length of a column name

unsigned int

ATTR_CURSOR_COMMIT_BEHAVIOR

How a COMMIT operation affects cursors and prepared statements in the database; values are:

  • OCCI_CURSOR_OPEN for preserving cursor state as before the commit operation

  • OCCI_CURSOR_CLOSED for cursors that are closed on COMMIT, although the application can once again execute the statement without preparing it again

int

ATTR_MAX_CATALOG_NAMELEN

Maximum length of a catalog (database) name

int

ATTR_CATALOG_LOCATION

Position of the catalog in a qualified table; values are:

  • OCCI_CL_START

  • OCCI_CL_END

int

ATTR_SAVEPOINT_SUPPORT

Identifies whether the database supports savepoints; values are:

  • OCCI_SP_SUPPORTED

  • OCCI_SP_UNSUPPORTED

int

ATTR_NOWAIT_SUPPORT

Identifies whether the database supports the nowait clause; values are:

  • OCCI_NW_SUPPORTED

  • OCCI_NW_UNSUPPORTED

int

ATTR_AUTOCOMMIT_DDL

Identifies whether the autocommit mode is required for DDL statements; values are:

  • OCCI_AC_DDL

  • OCCI_NO_AC_DDL

int

ATTR_LOCKING_MODE

Locking mode for the database; values are:

  • OCCI_LOCK_IMMEDIATE

  • OCCI_LOCK_DELAYED

int