Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include using oracle::occi::Environment; using oracle::occi::Connection; using namespace oracle::occi; using namespace std;

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; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

Why would someone send a request for admissions in law?

Answered: 1 week ago