/* Copyright © Oracle Corporation 1995. All Rights Reserved. */ /* ABSTRACT: This sample C program lists the employees assigned to each department in the sample multischema corporate_data database. The SQL module msdb_mod.sqlmod, which you link with this C program uses multischema naming to identify schema objects. */ #include #include main() { /* Declare the return status variable for error handling. */ int sql_return_status; /* Variables for program use */ char emp_id[6], emp_last_name[21], emp_first_name[21], dept_name[21], dept_code[5], dept_man_id[6]; void open_dept_cursor(); void fetch_dept_data(); void close_dept_cursor(); void open_emp_cursor(); void fetch_emp_data(); void close_emp_cursor(); /* Print main title. */ printf("%20s DEPARTMENT EMPLOYEE LISTING\n\n"," "); /* Open departments cursor */ open_dept_cursor(&sql_return_status); while (1) { /* Fetch department data. */ fetch_dept_data(&sql_return_status,dept_code,dept_name, dept_man_id); if (sql_return_status == 100) break; else if (sql_return_status != 0) sql_signal(); /* Print department data and employee headings. */ printf("\n"); printf("Department Code: %s\n",dept_code); printf("Department Name: %s\n",dept_name); printf("Dept Manager Id: %s\n\n" ,dept_man_id); printf("Employee Id %s Last Name %15s First Name \n"," "," "); /* Open the employees cursor. */ open_emp_cursor(&sql_return_status,dept_code); while (1) { /* Fetch employee data. */ fetch_emp_data(&sql_return_status,emp_id, emp_last_name,emp_first_name); if (sql_return_status == 100) break; else if (sql_return_status != 0) sql_signal(); /* Print employees data. */ printf("%6s %28s %25s \n", emp_id,emp_last_name,emp_first_name); } /* end employees while loop */ /* Close employees cursor. */ close_emp_cursor(&sql_return_status); }/* end departments while loop */ /* Close departments cursor. */ close_dept_cursor(&sql_return_status); } /* end main program */