Home | Previous Page | Next Page   Descriptor Function Reference > Accessor Functions >

mi_scan_projs()

The mi_scan_projs() function identifies each column that the SELECT clause of a query specifies.

Syntax

mi_smallint * mi_scan_projs(MI_AM_SCAN_DESC *scanDesc)
scanDesc
points to the scan descriptor.

Usage

Use the return value from mi_scan_nprojs() to determine the number of times to execute mi_scan_projs(). Then use mi_scan_projs() to identify columns that the return row must contain.

A qualification identifies a column by a number that locates the column in the row descriptor. The number 0 indicates the first column in the row descriptor. In the following example, mi_scan_projs() points to the values 1, 5, and 4:

SELECT column1, column5, column4 FROM table 

The row descriptor describes the columns in the order that they appear in the CREATE TABLE statement. The following example shows how to determine the data type of each projected column:

MI_TYPE_DESC *typedesc; 
MI_AM_TABLE_DESC*td;
MI_ROW_DESC *rd;
MI_AM_SCAN_DESC*sd;
mi_integer  n;
mi_smallint c, *projcols;   /* column identifiers */
rd = mi_tab_rowdesc(td);    /* describes a table row*/
n = mi_scan_nprojs(sd); /*How many columns are projected?*/
projcols=mi_scan_projs(sd);/* identifies projected columns*/

for (int i = 0; i < n; i++)
{
   c = projcols[i];       /* Get offset to row descriptor.*/
   /* Get data type for projected column. For example 
   ** my_data->col_type[c] = mi_column_typedesc(rd, c) */
}

Tip:
Because the access method needs to return data for only the columns that make up the projection, the access method can put a NULL value in the remaining columns. Eliminate unnecessary column data to improve performance and reduce the resources that the database server allocates to format and store the returned rows.

Return Values

Each of the small integers in the array that this function returns identifies a column by the position of that column in the row descriptor.

Related Topics

See the descriptions of:

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]