Return Codes
HCERR_OK
HCERR_OOM
HCERR_BAD_REQUEST
HCERR_NULL_SESSION
HCERR_INVALID_SESSION
HCERR_ILLEGAL_ARGUMENT
See Also
“hc_pstmt_create” on page 100
Querying With a Prepared Statement
The following code is an example of querying with a prepared statement. Error handling is
omitted. Two metadata elds are used with the denitions 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 today’s date
time(&t);
date = gmtime(&t);
// list all OIDs with today’s 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("today’s oid: %s\n", oid);
}
res = hc_qrs_free(rset);
QueryingWithaPreparedStatement
SunStorageTek 5800SystemClientAPIReferenceManual • June 2008110