Sun Microsystems 5800 Computer Drive User Manual


 
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 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);
QueryingWithaPreparedStatement
SunStorageTek 5800SystemClientAPIReferenceManual June 2008110