ReturnCodes
HCERR_OK
HCERR_OOM
HCERR_BAD_REQUEST
HCERR_NULL_SESSION
HCERR_INVALID_SESSION
HCERR_ILLEGAL_ARGUMENT
SeeAlso

hc_pstmt_create”on page 100

Querying Witha Prepared Statement

Thefollowing code is an example of querying with a prepared statement. Error handling is

omitted.Two metadata elds are used with the denitions from the schema:

<field name="test_date"type="date">
<field name="test_status"type="string">
hcerr_t res;
time_t t;
struct tm *date;
hc_pstmt_t *pstmt;
hc_query_result_set_t *rset;
hc_string_t selects[] = { "test_status"};
// get todays date
time(&t);
date = gmtime(&t);
// list all OIDs with todays date
res = hc_pstmt_create(session, "test_date = ?", &pstmt);
res = hc_pstmt_set_date(pstmt, 1, date);
res = hc_pstmt_query_ez(pstmt, NULL, 0, 2000, &rset);
while (1) {
hc_oid oid;
int finished;
res = hc_qrs_next_ez(rset, &oid, NULL, &finished);
if (finished)
break;
printf("todays oid: %s\n", oid);
}
res = hc_qrs_free(rset);
QueryingWitha Prepared Statement
SunStorageTek5800 System Client API Reference Manual • June 2008110