OCILIB (C and C++ Driver for Oracle)  4.4.0
Describing Schema Meta data and Objects

Detailed Description

Example
#include "ocilib.h"
void err_handler(OCI_Error *err)
{
printf("%s\n", OCI_ErrorGetString(err));
}
int main(void)
{
int i, n;
if (!OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT))
{
return EXIT_FAILURE;
}
cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
tbl = OCI_TypeInfoGet(cn, "user_tables", OCI_TIF_VIEW);
printf("Column Name Type Length Prec. Scale Null ?\n");
printf("----------------------------------------------------------------------\n");
for (i = 1; i <= n; i++)
{
printf("%-30s%-10s%-8i%-8i%-8i%-s\n",
OCI_GetColumnName(col),
OCI_GetColumnSQLType(col),
OCI_GetColumnSize(col),
OCI_GetColumnPrecision(col),
OCI_GetColumnScale(col),
OCI_GetColumnNullable(col) == TRUE ? "Y" : "N");
}
return EXIT_SUCCESS;
}

Functions

OCI_EXPORT OCI_TypeInfo *OCI_API OCI_TypeInfoGet (OCI_Connection *con, const otext *name, unsigned int type)
 Retrieve the available type info information. More...
 
OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetType (OCI_TypeInfo *typinf)
 Return the type of the type info object. More...
 
OCI_EXPORT OCI_Connection *OCI_API OCI_TypeInfoGetConnection (OCI_TypeInfo *typinf)
 Retrieve connection handle from the type info handle. More...
 
OCI_EXPORT boolean OCI_API OCI_TypeInfoFree (OCI_TypeInfo *typinf)
 Free a type info object. More...
 
OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetColumnCount (OCI_TypeInfo *typinf)
 Return the number of columns of a table/view/object. More...
 
OCI_EXPORT OCI_Column *OCI_API OCI_TypeInfoGetColumn (OCI_TypeInfo *typinf, unsigned int index)
 Return the column object handle at the given index in the table. More...
 
OCI_EXPORT const otext *OCI_API OCI_TypeInfoGetName (OCI_TypeInfo *typinf)
 Return the name described by the type info object. More...
 

Function Documentation

§ OCI_TypeInfoGet()

OCI_EXPORT OCI_TypeInfo* OCI_API OCI_TypeInfoGet ( OCI_Connection con,
const otext *  name,
unsigned int  type 
)

#include <ocilib.h>

Retrieve the available type info information.

Parameters
con- Connection handle
name- Table/view name to query for
type- Type of object
Note
Possible values for parameter type are :
  • OCI_UNKNOWN
  • OCI_TIF_TABLE
  • OCI_TIF_VIEW
  • OCI_TIF_TYPE
Returns
  • Type info handle on success = - NULL if the object does not exist
  • NULL on failure

Referenced by ocilib::TypeInfo::TypeInfo().

§ OCI_TypeInfoGetType()

OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetType ( OCI_TypeInfo typinf)

#include <ocilib.h>

Return the type of the type info object.

Parameters
typinf- Type info handle
Note
Possible values for parameter type are :
  • OCI_UNKNOWM
  • OCI_TIF_TABLE
  • OCI_TIF_VIEW
  • OCI_TIF_TYPE
Returns
Object type or OCI_UNKNOWN the input handle is NULL

Referenced by ocilib::TypeInfo::GetType().

§ OCI_TypeInfoGetConnection()

OCI_EXPORT OCI_Connection* OCI_API OCI_TypeInfoGetConnection ( OCI_TypeInfo typinf)

#include <ocilib.h>

Retrieve connection handle from the type info handle.

Parameters
typinf- Type info handle

Referenced by ocilib::TypeInfo::GetConnection().

§ OCI_TypeInfoFree()

OCI_EXPORT boolean OCI_API OCI_TypeInfoFree ( OCI_TypeInfo typinf)

#include <ocilib.h>

Free a type info object.

Parameters
typinf- Type info handle
Note
this call is optional. OCI_TypeInfo object are internally tracked and automatically freed when their related connection is freed
Returns
TRUE on success otherwise FALSE

§ OCI_TypeInfoGetColumnCount()

OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetColumnCount ( OCI_TypeInfo typinf)

#include <ocilib.h>

Return the number of columns of a table/view/object.

Parameters
typinf- Type info handle

Referenced by ocilib::TypeInfo::GetColumnCount().

§ OCI_TypeInfoGetColumn()

OCI_EXPORT OCI_Column* OCI_API OCI_TypeInfoGetColumn ( OCI_TypeInfo typinf,
unsigned int  index 
)

#include <ocilib.h>

Return the column object handle at the given index in the table.

Parameters
typinf- Type info handle
index- Column position
Returns
  • Column handle on success
  • NULL if index is out of bounds or on error

Referenced by ocilib::TypeInfo::GetColumn().

§ OCI_TypeInfoGetName()

OCI_EXPORT const otext* OCI_API OCI_TypeInfoGetName ( OCI_TypeInfo typinf)

#include <ocilib.h>

Return the name described by the type info object.

Parameters
typinf- Type info handle

Referenced by ocilib::TypeInfo::GetName().