#include <stdio.h>
#include <string.h>
#include "example_fcns.h"
#include "core07_structs.h"
#include "core07_cat.h"
const char *const description = "Demonstrates using an index for ordering";
{
STUDENT student_rec;
print_error (rc);
{
strcpy (student_rec.name, "Jeff");
hDB, TABLE_STUDENT, &student_rec, sizeof (student_rec), NULL);
print_error (rc);
{
strcpy (student_rec.name, "Brooke");
hDB, TABLE_STUDENT, &student_rec, sizeof (student_rec), NULL);
print_error (rc);
}
{
strcpy (student_rec.name, "Jonah");
hDB, TABLE_STUDENT, &student_rec, sizeof (student_rec), NULL);
print_error (rc);
}
{
strcpy (student_rec.name, "Norah");
hDB, TABLE_STUDENT, &student_rec, sizeof (student_rec), NULL);
print_error (rc);
}
{
strcpy (student_rec.name, "Micah");
hDB, TABLE_STUDENT, &student_rec, sizeof (student_rec), NULL);
print_error (rc);
}
else
print_error (rc);
}
return rc;
}
{
CLASS course_rec;
print_error (rc);
{
{
strcpy (course_rec.id, "ACCTG1A");
strcpy (course_rec.title, "Principles of Accounting");
hDB, TABLE_CLASS, &course_rec, sizeof (course_rec), NULL);
print_error (rc);
}
{
strcpy (course_rec.id, "MATH037");
strcpy (course_rec.title, "Finite Mathematics");
hDB, TABLE_CLASS, &course_rec, sizeof (course_rec), NULL);
print_error (rc);
}
{
strcpy (course_rec.id, "CAOTO15");
strcpy (course_rec.title, "Business Communications");
hDB, TABLE_CLASS, &course_rec, sizeof (course_rec), NULL);
print_error (rc);
}
{
strcpy (course_rec.id, "CBIS36");
strcpy (course_rec.title, "Systems Analysis and Design");
hDB, TABLE_CLASS, &course_rec, sizeof (course_rec), NULL);
print_error (rc);
}
{
strcpy (course_rec.id, "IBUS1");
strcpy (course_rec.title, "Introduction to International Business");
hDB, TABLE_CLASS, &course_rec, sizeof (course_rec), NULL);
print_error (rc);
}
else
print_error (rc);
}
return rc;
}
const char *student_name,
const char *course_id,
{
CLASS_ID_KEY classKey;
STUDENT_NAME_KEY studentKey;
ENROLLMENT enroll_rec;
print_error (rc);
{
strcpy (studentKey.name, student_name);
hDB, KEY_STUDENT_NAME, &studentKey, sizeof (studentKey),
&studentCursor);
print_error (rc);
{
strcpy (classKey.id, course_id);
hDB, KEY_CLASS_ID, &classKey, sizeof (classKey), &classCursor);
print_error (rc);
}
{
enroll_rec._begin_date_has_value =
RDM_TRUE;
strcpy (enroll_rec.status, "enrolled");
enroll_rec._status_has_value =
RDM_TRUE;
enroll_rec._current_grade_has_value =
RDM_FALSE;
enroll_rec._class_students_has_value =
RDM_FALSE;
enroll_rec._student_classes_has_value =
RDM_FALSE;
hDB, TABLE_ENROLLMENT, &enroll_rec, sizeof (enroll_rec),
&enrollmentCursor);
print_error (rc);
}
{
enrollmentCursor, REF_ENROLLMENT_CLASS_STUDENTS, classCursor);
print_error (rc);
}
{
enrollmentCursor, REF_ENROLLMENT_STUDENT_CLASSES,
studentCursor);
print_error (rc);
}
else
print_error (rc);
}
return rc;
}
{
rc = register_for_course ("Jeff", "IBUS1", hDB);
rc = register_for_course ("Jeff", "CAOTO15", hDB);
rc = register_for_course ("Jeff", "ACCTG1A", hDB);
rc = register_for_course ("Brooke", "CBIS36", hDB);
rc = register_for_course ("Brooke", "IBUS1", hDB);
rc = register_for_course ("Jonah", "MATH037", hDB);
rc = register_for_course ("Jonah", "CBIS36", hDB);
rc = register_for_course ("Norah", "IBUS1", hDB);
rc = register_for_course ("Norah", "ACCTG1A", hDB);
rc = register_for_course ("Norah", "MATH037", hDB);
rc = register_for_course ("Micah", "ACCTG1A", hDB);
return rc;
}
{
STUDENT student_rec;
CLASS course_rec;
print_error (rc);
{
printf ("\nList of courses each student is registered for\n");
print_error (rc);
{
studentCursor, &student_rec, sizeof (student_rec), NULL);
print_error (rc);
printf ("%s\n", student_rec.name);
studentCursor, REF_ENROLLMENT_STUDENT_CLASSES,
&enrollmentCursor);
print_error (rc);
{
ENROLLMENT enroll_rec;
char begin_date[100];
enrollmentCursor, &enroll_rec, sizeof (enroll_rec), NULL);
print_error (rc);
sizeof (begin_date), NULL);
print_error (rc);
enrollmentCursor, REF_ENROLLMENT_CLASS_STUDENTS,
&classCursor);
classCursor, &course_rec, sizeof (course_rec), NULL);
print_error (rc);
printf (
"\t%s: %s\t%s\n", begin_date, course_rec.id,
course_rec.title);
}
}
if (classCursor)
if (studentCursor)
if (enrollmentCursor)
}
return rc;
}
int main_core07 (int argc, const char *const *argv)
{
print_error (rc);
{
rc = exampleOpenEmptyDatabase (&hTFS, &hDB, "core07", core07_cat);
{
rc = insertStudents (hDB);
{
rc = insertClasses (hDB);
}
{
rc = registerForClasses (hDB);
}
{
rc = displayClassRoster (hDB);
}
exampleCleanup (hTFS, hDB);
}
}
return (int) rc;
}