#include <stdio.h>
#include <string.h>
#include "example_fcns.h"
#include "core03_structs.h"
#include "core03_cat.h"
const char *const description =
"Demonstrates associating rows in one table with a row in another table";
const char *artistName,
{
ARTIST artist_rec;
artist_rec.id = 0;
strncpy (artist_rec.name, artistName, sizeof (artist_rec.name));
hDB, TABLE_ARTIST, &artist_rec, sizeof (artist_rec), artistCursor);
print_error (rc);
return rc;
}
const char **albumList,
size_t listSize)
{
int ii;
for (ii = 0; ii < (int) listSize; ii++)
{
ALBUM album_rec;
strncpy (album_rec.title, albumList[ii], sizeof (album_rec.title));
hDB, TABLE_ALBUM, &album_rec, sizeof (album_rec), &albumCursor);
print_error (rc);
{
print_error (rc);
}
}
return rc;
}
{
print_error (rc);
{
print_error (rc);
}
{
{
artistCursor, COL_ARTIST_NAME, Artist, sizeof (Artist), NULL);
print_error (rc);
{
printf ("\nArtist: %s\n", Artist);
artistCursor, REF_ALBUM_ID, &albumCursor);
print_error (rc);
{
printf ("\nAlbums:");
{
albumCursor, COL_ALBUM_TITLE, Title, sizeof (Title),
NULL);
print_error (rc);
{
printf ("\t%s\n", Title);
}
}
{
}
else
{
print_error (rc);
}
}
}
}
{
}
else
{
print_error (rc);
}
if (albumCursor)
if (artistCursor)
}
return rc;
}
static const char *doors_albums[] = {"The Doors", "Strange Days",
"Waiting for the Sun"};
static const char *stones_albums[] = {"The Rolling Stones", "Out of Our Heads",
"Beggars Banquet", "Tattoo You"};
static const char *nirvana_albums[] = {"Bleach", "Nevermind", "In Utero"};
{
print_error (rc);
{
rc = insertArtist (hDB, "The Doors", &artistCursor);
print_error (rc);
{
rc = insertAlbums (
hDB, artistCursor, doors_albums,
(sizeof (doors_albums) / sizeof (char *)));
}
else
}
print_error (rc);
{
rc = insertArtist (hDB, "The Rolling Stones", &artistCursor);
{
rc = insertAlbums (
hDB, artistCursor, stones_albums,
(sizeof (stones_albums) / sizeof (char *)));
}
else
}
print_error (rc);
{
rc = insertArtist (hDB, "Nirvana", &artistCursor);
{
rc = insertAlbums (
hDB, artistCursor, nirvana_albums,
(sizeof (nirvana_albums) / sizeof (char *)));
}
else
}
return rc;
}
int main_core03 (int argc, const char *const *argv)
{
print_error (rc);
{
rc = exampleOpenEmptyDatabase (&hTFS, &hDB, "core03", core03_cat);
{
rc = insertAllArtists (hDB);
{
rc = readAllAlbums (hDB);
}
exampleCleanup (hTFS, hDB);
}
}
return (int) rc;
}