MemCom Reference Manual > MemCom C API Manual Pages > Sparse Table Functions > mcSTrowAppend

Name

mcSTrowAppend — Append one or more empty rows to a sparse-table dataset

Synopsis

#include <memcom.h>

int mcSTrowAppend(int dsid, mcInt64 num);

Description

mcSTrowAppend appends, for the sparse-table dataset identified by dsid, num empty rows.

Parameters

dsid (input)

Dataset identifier.

num (input)

Defines the number of empty rows that are to be appended to the dataset.

Return Value

If the rows could be added successfully, the row index of the first newly added row is returned (a positive number). Otherwise, a negative value indicating the MemCom error number is returned.

See Also

mcSTdatasetClear, mcSTrowNum

Example

/*
 * Appends a single row to an existing ST dataset.
 */
void
append_to_fields(int handle, const char* gname, const char* type)
{
    const char* setname = "FIELDS";
    mcInt64     col_gname;
    mcInt64     col_type;
    mcInt64     row_index;

    /* Open the dataset. */
    dsid = mcSTdatasetOpen(handle, setname);

    /* Get the column indices. */
    col_gname = mcSTcolFind(dsid, "GNAME");
    col_type  = mcSTcolFind(dsid, "TYPE");

    /* Append a new row. */
    mcSTrowAppend(dsid, 1);
    row_index = mcSTrowNum(dsid);

    /* Set the cells for this row. */
    mcSTcellSetK(dsid, row_index, col_gname, gname);
    mcSTcellSetK(dsid, row_index, col_type, type);

    /* Close the dataset. */
    mcSTdatasetClose(dsid);
}