Question
Please help me format this code correctly.As visual studio is giving m e errors. the output should look like the photo in attachment. #include #include
Please help me format this code correctly.As visual studio is giving m e errors. the output should look like the photo in attachment.
#include
int main(void) { Environment* env = nullptr; Connection* conn = nullptr; Statement* stmt = nullptr; ResultSet* rs = nullptr; int num; string str; string user = "dbs211_202f31"; string pass = "15004242"; string constr = "myoracle12c.senecacollege.ca:1521/oracle12c"; try { env = Environment::createEnvironment(Environment::DEFAULT); conn = env - > createConnection(user, pass, constr); std::cout << "connection is successful" << endl; Statement* stmt = conn->createStatement(); ResultSet * rs = stmt->executeQuery("SELECT employeenumber, firstname, lastname, phone, extension FROM employees, offices WHERE employees.officecode = offices.officecode and LOWER(city) = 'san francisco' ORDER by employeenumber"); cout << "--------------------------Report 1 (Employee Report)------------------------------" << endl; cout << "Employee ID First Name Last Name Phone Extension" << endl; cout << " ---------- ---------- --------- ----- ---------" << endl; while (rs->next()) { int employeenumber = rs->getInt(1); string fname = rs->getString(2); string lname = rs->getString(3); string phone = rs->getString(4); string extension = rs->getString(5); cout << " "; cout.width(12); cout.setf(ios::left); cout << employeenumber; cout << " "; cout.width(14); cout.setf(ios::left); cout << fname; cout.width(8); cout << lname; cout.setf(ios::left); cout.width(4); cout << ""; cout << phone; cout.width(8); cout << " "; cout << extension << endl; } stmt = conn - > createStatement(); rs = stmt->executeQuery("SELECT employeeNumber, firstName, lastName, phone, extension FROM employees e, offices o WHERE employeeNumber IN(SELECT e1.reportsTo FROM employees e1 LEFT OUTER JOIN employees e2 ON e1.reportsTo = e2.employeeNumber) and e.officeCode = o.officeCode ORDER BY employeeNumber"); cout << "--------------------------Report 2 (Manager Report)------------------------------" << endl; cout << "Employee ID First Name Last Name Phone Extension" << endl; cout << " ---------- ---------- --------- ----- ---------" << endl; while (rs->next()) { int employeenumber = rs->getInt(1); string fname = rs->getString(2); string lname = rs->getString(3); string phone = rs->getString(4); string extension = rs->getString(5); cout << " "; cout.width(12); cout.setf(ios::left); cout << employeenumber; cout << " "; cout.width(14); cout.setf(ios::left); cout << fname; cout.width(8); cout << lname; cout.setf(ios::left); cout.width(4); cout << ""; cout << phone; cout.width(8); cout << " "; cout << extension << endl; } env - > terminateConnection(conn); Environment::terminateEnvironment(env); } catch (SQLException& sqlExcp) { cout << "error"; cout << sqlExcp.getErrorCode() << ": " << sqlExcp.getMessage(); } return 0; }