Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

cci_schema_info

Description

The cci_schema_info function gets schema information. If it is performed successfully, the results are managed by the request handle and can be fetched by fetch and getdata. If you want to retrieve a class_name and attr_name by using pattern matching of the LIKE statement, you should configure flag.

Two types of flags, CCI_CLASS_NAME_PATTERN_MATCH, and CCI_ATTR_NAME_PATTERN_MATCH, are used for pattern matching; you can configure these two flags by using the OR operator ( | ). To use pattern matching, search by using the LIKE statement. For example, to search the information on a column of which class_name is "athlete" and attr_name is "code," you can enter as follows (in the example, "%code" is entered in the value of attr_name).

cci_schema_info(conn, CCI_SCH_ATTRIBUTE, "athlete", "%code", CCI_ATTR_NAME_PATTERN_MATCH, &error);The following table shows records composition of each type.

The table below shows record type for each type.

Record for Each Type

Type

Column Order

Column Name

Column Type

CCI_SCH_CLASS

1

NAME

char*

2

TYPE

short
0 : system class
1 : vclass
2 : class
3 : proxy

CCI_SCH_VCLASS

1

NAME

char*

2

TYPE

short
1 : vclass
3 : proxy

CCI_SCH_QUERY_SPEC

1

QUERY_SPEC

char*

CCI_SCH_ATTRIBUTE

1

NAME

char*

2

DOMAIN

int

3

SCALE

int

4

PRECISION

int

5

INDEXED

int
1 : indexed

6

NON_NULL

int
1 : non null

7

SHARED

int
1 : shared

8

UNIQUE

int
1 : unique

9

DEFAULT

void*

10

ATTR_ORDER

int
base : 1

11

CLASS_NAME

char*

12

SOURCE_CLASS

char*

13

IS_KEY

short
1 : key

When the attribute of the CCI_SCH_CLASS_ATTRIBUTE column is INSTANCE or SHARED, the order and the name values are identical to those of the column of CCI_SCH_ATTRIBUTE.

 

 

 

CCI_SCH_CLASS_METHOD

1

NAME

char*

2

RET_DOMAIN

int

3

ARG_DOMAIN

char*

CCI_SCH_METHOD_FILE

1

METHOD_FILE

char*

CCI_SCH_SUPERCLASS

1

CLASS_NAME

char*

2

TYPE

short

CCI_SCH_SUBCLASS

1

CLASS_NAME

char*

2

TYPE

short

CCI_SCH_CONSTRAINT

1

TYPE
0 : unique
1 : index
2 : reverse unique
3 : reverse index

int

2

NAME

char*

3

ATTR_NAME

char*

4

NUM_PAGES

int

5

NUM_KEYS

int

6

PRIMARY_KEY
1 : primary key

short

7

KEY_ORDER

short
base : 1

CCI_SCH_TRIGGER

1

NAME

char*

2

STATUS

char*

3

EVENT

char*

4

TARGET_CLASS

char*

5

TARGET_ATTR

char*

6

ACTION_TIME

char*

7

ACTION

char*

8

PRIORITY

float

9

CONDITION_TIME

char*

10

CONDITION

char*

CCI_SCH_CLASS_PRIVILEGE

1

CLASS_NAME

char*

2

PRIVELEGE

char*

3

GRANTABLE

char*

CCI_SCH_ATTR_PRIVILEGE

1

ATTR_NAME

char*

2

PRIVILEGE

char*

3

GRANTABLE

char*

CCI_SCH_DIRECT_SUPER_CLASS

1

CLASS_NAME

char*

2

SUPER_CLASS_NAME

char*

CCI_SCH_PRIMARY_KEY

1

CLASS_NAME

char*

2

ATTR_NAME

char*

3

KEY_SEQ

short
base : 1

4

KEY_NAME

char*

CCI_SCH_IMPORTED_KEYS

Used to retrieve primary key columns that are referred by a foreign key column in a given table. The results are sorted by PKTABLE_NAME and KEY_SEQ.

If this type is specified as a parameter, a foreign key table is specified for class_name, and NULL is specified for attr_name.

1

PKTABLE_NAME

char**

2

PKCOLUMN_NAME

char**

3

FKTABLE_NAME

char**

4

FKCOLUMN_NAME

char**

5

KEY_SEQ

char**

6

UPDATE_ACTION
cascade=0
restrict=1
no action=2
set null=3

int*

7

DELETE_ACTION
cascade=0
restrict=1
no action=2
set null=3

int*

8

FK_NAME

char**

9

PK_NAME

char**

CCI_SCH_EXPORTED_KEYS
Used to retrieve primary key columns that are referred by all foreign key columns. The results are sorted by FKTABLE_NAME and KEY_SEQ.

If this type is specified as a parameter, a primary key table is specified for class_name, and NULL is specified for attr_name.

1

PKTABLE_NAME

char**

2

PKCOLUMN_NAME

char**

3

FKTABLE_NAME

char**

4

FKCOLUMN_NAME

char**

5

KEY_SEQ

char**

6

UPDATE_ACTION
cascade=0
restrict=1
no action=2
set null=3

int*

7

DELETE_ACTION
cascade=0
restrict=1
no action=2
set null=3

int*

8

FK_NAME

char**

9

PK_NAME

char**

CCI_SCH_CROSS_REFERENCE
Used to retrieve foreign key information when primary keys and foreign keys in a given table are cross referenced. The results are sorted by FKTABLE_NAME and KEY_SEQ.

If this type is specified as a parameter, a primary key is specified for class_name, and a foreign key table is specified for attr_name.

1

PKTABLE_NAME

char**

2

PKCOLUMN_NAME

char**

3

FKTABLE_NAME

char**

4

FKCOLUMN_NAME

char**

5

KEY_SEQ

char**

6

UPDATE_ACTION
cascade=0
restrict=1
no action=2
set null=3

int*

7

DELETE_ACTION
cascade=0
restrict=1
no action=2
set null=3

int*

8

FK_NAME

char**

9

PK_NAME

char**

In the cci_schema_info function, the type argument supports the pattern matching of the LIKE statement for the class_name and attr_name.

type, class_name, and attr_name That Supports Pattern Matching

type

class_name

attr_name

CCI_SCH_CLASS (VCLASS)

string

NULL

CCI_SCH_ATTRIBUTE (CLASS ATTRIBUTE)

string

string or NULL
(If the value is NULL and the flag is CCI_ATTR_NAME_PATTERN_MATCH, information on all columns of the table will be displayed.)

CCI_SCH_CLASS_PRIVILEGE

string

NULL

CCI_SCH_ATTR_PRIVILEGE

NULL

string

CCI_SCH_PRIMARY_KEY

string

NULL

CCI_SCH_TRIGGER

string

NULL

If the pattern flag is not configured, exact matching will be used for the given table and column names; in this case, no result will be returned if the value is NULL. If flag is configured and the value is NULL, the result will be the same as when "%" is given in the LIKE statement

Note TYPE column of CCI_SCH_CLASS and CCI_SCH_VCLASS: The proxy type is added. When used in OLEDB, ODBC or PHP, vclass is represented without distinguishing between proxy and vclass.

Syntax

int cci_schema_info(int conn_handle, T_CCI_SCHEMA_TYPE type, char *class_name, char *attr_name, char flag, T_CCI_ERROR *err_buf)

  • conn_handle: (IN) Connection handle
  • type: (IN) Schema type
  • class_name: (IN) Class name or NULL
  • attr_name: (IN) Attribute name or NULL
  • flag: (IN) Pattern matching flag (CCI_CLASS_NAME_PATTERN_MATCH or CCI_ATTR_NAME_PATTERN_MATCH)
  • err_buf: (OUT) Database error buffer
Return Value
  • Success: Request handle
  • Failure: Error code
Error Code
  • CCI_ER_CON_HANDLE
  • CCI_ER_DBMS
  • CCI_ER_COMMUNICATION
  • CCI_ER_NO_MORE_MEMORY
  • CCI_ER_CONNECT
Example

    conn = cci_connect ("localhost", 33000, "demodb", "dba", "");

 

// get all columns’ information of table "athlete"

    req = cci_schema_info(conn, CCI_SCH_ATTRIBUTE, "athlete", NULL, CCI_ATTR_NAME_PATTERN_MATCH, &error);

 

// get info. of table "athlete"’s column "code".

//req = cci_schema_info(conn, CCI_SCH_ATTRIBUTE, "athlete", "code", 0, &error);

    if (req < 0 )

    {

        fprintf(stdout, "(%s, %d) ERROR : %s [%d] ", __FILE__, __LINE__,error.err_msg, error.err_code );

        goto _END;

    }

res_col_info = cci_get_result_info(req, &cmd_type, &col_count);

    if (!res_col_info && col_count == 0)

    {

        fprintf(stdout, "(%s, %d) ERROR : cci_get_result_info ", __FILE__, __LINE__);

        goto _END;

    }

    res = cci_cursor(req, 1, CCI_CURSOR_FIRST, &error);

    if (res == CCI_ER_NO_MORE_DATA)

    {

        goto _END_WHILE;

    }

    if (res < 0)

    {

        fprintf(stdout, "(%s, %d) ERROR : %s [%d] ", __FILE__, __LINE__,error.err_msg, error.err_code );

        goto _END_WHILE;

    }

 

 

    while (1)

    {

        res = cci_fetch(req, &error);

        if (res <  0)

        {

            fprintf(stdout, "(%s, %d) ERROR : %s [%d] ", __FILE__, __LINE__,error.err_msg, error.err_code );

            goto _END_WHILE;

        }

 

        for (i = 1; i <= col_count; i++)

        {

            if ((res = cci_get_data(req, i, CCI_A_TYPE_STR, &buffer, &ind))<0)

            {

                goto _END_WHILE;

            }

            strcat(query_result_buffer, buffer);

            strcat(query_result_buffer, "|");

        }

        strcat(query_result_buffer, " ");

 

        res = cci_cursor(req, 1, CCI_CURSOR_CURRENT, &error);

        if (res == CCI_ER_NO_MORE_DATA)

        {

            goto _END_WHILE;

        }

        if (res < 0)

        {

            fprintf(stdout, "(%s, %d) ERROR : %s [%d] ", __FILE__, __LINE__,error.err_msg, error.err_code );

            goto _END_WHILE;

        }

    }

_END_WHILE:

    res = cci_close_req_handle(req);

    if (res <  0)

        goto _END;

 

_END:

    if (req > 0)

        cci_close_req_handle(req);

    if ( conn > 0)

        res = cci_disconnect(conn, &error);

    if (res < 0)

        fprintf(stdout, "(%s, %d) ERROR : %s [%d] ", __FILE__, __LINE__,error.err_msg, error.err_code );

 

        fprintf(stdout, "Result : %s ", query_result_buffer);

 

    return 0;