Products Support Documentation Download
Macros | Functions
Core04.c File Reference

Source code for the RDM core04 example. More...

#include <stdio.h>
#include <string.h>
#include "print_error.h"
#include "rdm.h"
#include "core04_db_structs.h"
#include "core04_db_cat.h"

Macros

#define RLEN(x)   (sizeof (x) / sizeof (x[0]))
 Macro to determine number of elements in an array of ptrs.
 

Functions

RDM_RETCODE openEmptyDatabase (RDM_DB *pDB)
 Initialize the RDM runtime library for use in the core04 example. More...
 
RDM_RETCODE insertArtist (RDM_DB hDB, const char *artistName, RDM_CURSOR *artistCursor)
 Insert an artist. More...
 
RDM_RETCODE insertAlbum (RDM_DB hDB, RDM_CURSOR artistCursor, const char *albumTitle, const char **trackList, size_t listSize)
 Insert all of the albums associated with the artist. More...
 
RDM_RETCODE readAllAlbums (RDM_DB hDB)
 Read all the artists and the associated albums and tracks. More...
 
int main (void)
 Main function for core04 example. More...
 

Detailed Description

Source code for the RDM core04 example.

Function Documentation

◆ insertAlbum()

RDM_RETCODE insertAlbum ( RDM_DB  hDB,
RDM_CURSOR  artistCursor,
const char *  albumTitle,
const char **  trackList,
size_t  listSize 
)

Insert all of the albums associated with the artist.

This function adds one more row to the ARTIST table in the core03 database and one to many rows to the ALBUM table associated with the given artist.

In this version of the example, the function will obtain the ID for the artist and insert it into the record. This will automatically generate the reference links between the artist and the album on insert rather than later using the rdm_cursorLinkRow() function like the Core03 popcorn example.

Returns
Returns an RDM_RETCODE code (sOKAY if successful)
Parameters
[in]hDB[in] Database handle to open database
[in]artistCursor[in] Cursor of the artist
[in]albumTitle[in] Artist name to insert
[in]trackList[in] List of album names for the artist
[in]listSize[in] Number of album names in the list

◆ insertArtist()

RDM_RETCODE insertArtist ( RDM_DB  hDB,
const char *  artistName,
RDM_CURSOR *  artistCursor 
)

Insert an artist.

This function adds one more row to the ARTIST table in the core03 database.

Returns
Returns an RDM_RETCODE code (sOKAY if successful)
Parameters
[in]hDB[in] Database handle to open database
[in]artistName[in] Artist name to insert
[out]artistCursor[out] Cursor to the the row we just inserted

◆ main()

int main ( void  )

Main function for core04 example.

The function initializes the RDM environment and runs the create, read operations.

Returns
Returns the RDM_RETCODE on exit.

◆ openEmptyDatabase()

RDM_RETCODE openEmptyDatabase ( RDM_DB *  pDB)

Initialize the RDM runtime library for use in the core04 example.

This function initializes the RDM Transactional File Server (TFS) to use the EMBEDED TFS implementation. It also allocates a database handle and opens the "core04" database in exclusive mode. Exclusve mode does not require database locks or transactions.

Returns
Returns RDM_RETCODE status code (sOKAY if successful)
Parameters
[out]pDB[out] Pointer to the RDM database handle

◆ readAllAlbums()

RDM_RETCODE readAllAlbums ( RDM_DB  hDB)

Read all the artists and the associated albums and tracks.

This function reads and displays each row from the ARTIST table in the core04 database and the ALBUMS and TRACKS associated with the artist.

Returns
Returns an RDM_RETCODE code (sOKAY if successful)
Parameters
[in]hDB[in] Database handle to open database