OCILIB (C Driver for Oracle) 3.9.2
Functions
Describing Schema Metadata and Objects

Detailed Description

Example
    
#include "ocilib.h"

int main(void)
{
    OCI_Connection *cn;
    OCI_TypeInfo *tbl;
    int i,n;

    if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
        return EXIT_FAILURE;

    cn  = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
    tbl = OCI_TypeInfoGet(cn, "products", OCI_TIF_TABLE);

    if (tbl != NULL)
    {
        printf ("Column Name         Type      Length  Prec.   Scale   Null ?\n");
        printf ("----------------------------  ------------------------------\n");

        n = OCI_TypeInfoGetColumnCount(tbl);
   
        for(i = 1; i <= n; i++)
        {
            OCI_Column *col = OCI_TypeInfoGetColumn(tbl, i);

            printf("%-20s%-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");
        }
    }

    OCI_Cleanup();

    return EXIT_SUCCESS;
}

Functions

OCI_EXPORT OCI_TypeInfo *OCI_API OCI_TypeInfoGet (OCI_Connection *con, const mtext *name, unsigned int type)
 Retrieve the available type info information.
OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetType (OCI_TypeInfo *typinf)
 Return the type of the type info object.
OCI_EXPORT boolean OCI_API OCI_TypeInfoFree (OCI_TypeInfo *typinf)
 Free a type info object.
OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetColumnCount (OCI_TypeInfo *typinf)
 Retruns the number of columns of a table/view/object.
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.
OCI_EXPORT const mtext *OCI_API OCI_TypeInfoGetName (OCI_TypeInfo *typinf)
 Return the name described by the type info object.

Function Documentation

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

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

Definition at line 76 of file typeinfo.c.

References OCI_TypeInfoFree().

OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetType ( OCI_TypeInfo typinf)

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

Definition at line 469 of file typeinfo.c.

OCI_EXPORT boolean OCI_API OCI_TypeInfoFree ( OCI_TypeInfo typinf)

Free a type info object.

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

Definition at line 440 of file typeinfo.c.

Referenced by OCI_TypeInfoGet().

OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetColumnCount ( OCI_TypeInfo typinf)

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

Parameters:
typinf- Type info handle

Definition at line 485 of file typeinfo.c.

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.

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

Definition at line 501 of file typeinfo.c.

OCI_EXPORT const mtext* OCI_API OCI_TypeInfoGetName ( OCI_TypeInfo typinf)

Return the name described by the type info object.

Parameters:
typinf- Type info handle
Returns:

Definition at line 519 of file typeinfo.c.