30 printf(
"%s() returned error %d: %s\n", foo, st,
ups_strerror(st));
36 #define DBNAME_CUSTOMER 1 37 #define DBNAME_ORDER 2 39 #define MAX_CUSTOMERS 4 58 main(
int argc,
char **argv) {
78 { 1,
"Alan Antonov Corp." },
79 { 2,
"Barry Broke Inc." },
80 { 3,
"Carl Caesar Lat." },
81 { 4,
"Doris Dove Brd." }
98 error(
"ups_env_create", st);
109 error(
"ups_env_create_db (customer)", st);
112 error(
"ups_env_create_db (order)", st);
115 for (i = 0; i <
MAX_DBS; i++) {
118 printf(
"ups_cursor_create() failed with error %d\n", st);
125 key.
size =
sizeof(int);
126 key.
data = &customers[i].
id;
129 record.
data = &customers[i];
133 error(
"ups_db_insert (customer)", st);
138 key.
size =
sizeof(int);
142 record.
data = &orders[i];
146 error(
"ups_db_insert (order)", st);
156 for (i = 0; i <
MAX_DBS; i++) {
159 error(
"ups_cursor_close", st);
163 error(
"ups_env_close", st);
168 error(
"ups_env_open", st);
171 error(
"ups_env_open_db (customer)", st);
174 error(
"ups_env_open_db (order)", st);
177 for (i = 0; i <
MAX_DBS; i++) {
180 printf(
"ups_cursor_create() failed with error %d\n", st);
202 error(
"ups_cursor_next(customer)", st);
208 printf(
"customer %d ('%s')\n", customer->
id, customer->
name);
221 error(
"ups_cursor_next(order)", st);
229 printf(
" order: %d (assigned to %s)\n",
239 error(
"ups_cursor_next(order)", st);
250 error(
"ups_env_close", st);
252 printf(
"success!\n");
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_open(ups_env_t **env, const char *filename, uint32_t flags, const ups_parameter_t *param)
UPS_EXPORT const char *UPS_CALLCONV ups_strerror(ups_status_t status)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_close(ups_env_t *env, uint32_t flags)
int main(int argc, char **argv)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_db_insert(ups_db_t *db, ups_txn_t *txn, ups_key_t *key, ups_record_t *record, uint32_t flags)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_cursor_move(ups_cursor_t *cursor, ups_key_t *key, ups_record_t *record, uint32_t flags)
Include file for upscaledb embedded database.
struct ups_cursor_t ups_cursor_t
UPS_EXPORT ups_status_t UPS_CALLCONV ups_cursor_close(ups_cursor_t *cursor)
void error(const char *foo, ups_status_t st)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_open_db(ups_env_t *env, ups_db_t **db, uint16_t name, uint32_t flags, const ups_parameter_t *params)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_create(ups_env_t **env, const char *filename, uint32_t flags, uint32_t mode, const ups_parameter_t *param)
UPS_EXPORT ups_status_t UPS_CALLCONV ups_env_create_db(ups_env_t *env, ups_db_t **db, uint16_t name, uint32_t flags, const ups_parameter_t *params)
#define UPS_PARAM_KEY_TYPE
UPS_EXPORT ups_status_t UPS_CALLCONV ups_cursor_create(ups_cursor_t **cursor, ups_db_t *db, ups_txn_t *txn, uint32_t flags)
#define UPS_KEY_NOT_FOUND
struct ups_env_t ups_env_t