2 #include "monetdb/monetdb.h"
4 #define QUERY "select al.title from artist ar, album al where ar.artistId = al.artistId and ar.name = '?'"
6 static void mdb_001 (mdbconn_t
*conn
, char *name
) {
7 printf("-= %s =-\n", name
);
8 mdbres_t
*res
= mdb_exec(conn
, QUERY
, name
, NULL
);
9 if (0 == res
->status
) {
10 while (mdb_fetch(res
))
11 printf("%s\n", mdb_get(res
, 0));
13 printf("%s\n", res
->msg
);
17 static void mdb_002 (mdbconn_t
*conn
, char **names
, int name_count
) {
18 mdbres_t
*res
= mdb_prepare(conn
, QUERY
);
19 if (0 == res
->status
) {
20 for (int i
= 0; i
< name_count
; ++i
) {
21 printf("-= %s =-\n", names
[i
]);
22 if (0 == mdb_pexec(conn
, res
, names
[i
], NULL
))
23 while (mdb_fetch(res
))
24 printf("%s\n", mdb_get(res
, 0));
27 printf("%s\n", res
->msg
);
31 char *names
[] = { "Jimi Hendrix", "Rush", "Creedence Clearwater Revival" };
32 static void mdb_test () {
33 mdbconn_t
*conn
= mdb_connect("localhost", 50000, "chinook", "monetdb", "monetdb");
34 if (0 == conn
->status
) {
35 mdb_001(conn
, "Led Zeppelin");
36 mdb_002(conn
, names
, sizeof(names
)/sizeof(char*));
38 printf("%s\n", conn
->msg
);