SlideShare a Scribd company logo
Part A:
Purpose:
This laboratory provides some experience working with the C++
programming language that has an SQL query and SQL update
embedded in it.
Procedure:
Follow the instructions below.
Be sure to load the C++ to ProQueryExample code presented in
the Appendix A below.
In your
ProQueryExample.cpp source file, modify the source code so
that it changes the customer balance of Streaming Direct from
$210.40 to $337.26. Rerun the query in step 3 above. Modify
the source to return the balance of Streaming Direct to $210.40.
Rerun the query in step 3 above. Print out a copy of your
output.
Submit a cover sheet, a copy of your output, and the source
code that you used to obtain it. Follow any additional
instructions that your instructor may give you.
Appendix A
/*
* Name: ProQueryExample.cpp
*
* Description
* This source code displays a join of the invoice and
* customer tables. In addition this source code updates the
Streaming
* Direct customer name to Direct Sports and then returns the
name back
* to Streaming Direct.
*
* Remarks:
* Author Date Comment
* Mike Lukens 08/08/2008 initial code
*
*/
#include
#include
#include
using namespace oracle::occi;
using namespace std;
class occiIntf
{
public:
//constructor
occiIntf ( string login, string password, string dbStr )
{
//setup the environment which Oracle requires
environ = Environment::createEnvironment (
Environment::DEFAULT );
try
{
//create a connection to the database
connect = environ->createConnection ( login,
password, dbStr );
}
catch ( SQLException excpt )
{
cout << "Exception thrown by createConnection"
<< endl;
cout << "Error code: "<< excpt.getErrorCode ( ) <<
endl;
cout << excpt.getMessage ( ) << endl;
system ( "pause" );
exit ( 1 );
}
}
//destructor
~occiIntf ( )
{
//make sure to clean up the connection and the
environment when
//we are done!
environ->terminateConnection ( connect );
Environment::terminateEnvironment ( environ );
}
//update a field
void updateField ( string name, string id )
{
//change the customer name to/from Direct Sports in
CUSTOMER table
string sqlStatmt
= "UPDATE customer SET cust_name = :x WHERE
cust_id = :y";
statmt = connect->createStatement ( sqlStatmt );
try
{
//substitute the customer name and id into the SQL
statement
statmt->setString ( 1, name );
statmt->setString ( 2, id );
statmt->executeUpdate ();
cout << "Update succeededn" << endl;
}
catch ( SQLException excpt )
{
cout << "Exception thrown by updateField" <<
endl;
cout << "Error code: "<< excpt.getErrorCode ( ) <<
endl;
cout << excpt.getMessage ( ) << endl;
}
connect->terminateStatement ( statmt );
}
//display the invoice number, date, and customer name
void displayAllRows ( )
{
//create the SQL statement
string sqlStatmt
= "SELECT invoice_num, invoice_date, cust_name
FROM invoice, customer WHERE invoice.cust_id =
customer.cust_id";
//instantiate the statement object from our connection object
//using the SQL string to initialize the statement
statmt = connect->createStatement ( sqlStatmt );
try
{
//execute the query and point to the result set
//in order to loop through the returned data.
ResultSet *resSet = statmt->executeQuery ( );
//display the column headers
cout << endl
<< setw ( 5 ) << "INV #" << " "
<< setw ( 9 ) << "DATE " << " "
<< setw ( 20 ) << "CUSTOMER NAME" <<
endl;
//keep getting results until there are none
while ( resSet->next ( ) )
{
//extract each attribute value which is a string
cout << setw ( 5 ) << right << resSet->getString
( 1 ) << " "
<< setw ( 9 ) << resSet->getString ( 2 ) <<
" "
<< setw ( 30 ) << left << resSet->getString
( 3 ) << endl;
}
cout << endl;
//close the result set object when done
statmt->closeResultSet ( resSet );
}
catch ( SQLException excpt )
{
cout << "Exception thrown by displayAllRows." <<
endl;
cout << "Error code: " << excpt.getErrorCode ( ) <<
endl;
cout << excpt.getMessage ( ) << endl;
}
//done with statement
connect->terminateStatement ( statmt );
}
private:
//variables required by OCCI
Environment * environ;
Connection * connect;
Statement * statmt;
}; //end of occiIntf class
void main ( )
{
string dbStr = "ECET450";
string login;
string password;
cout << "Enter your Oracle login: ";
cin >> login;
cout << "Enter your Oracle password: ";
cin >> password;
system ( "CLS" ); //clear the screen
cout << "Demonstration of a query using OCCI" << endl;
// First create an object that is connected with the Oracle
database.
occiIntf * database = new occiIntf ( login, password, dbStr
);
cout << "Display invoice number, date, and customer name"
<< endl;
database->displayAllRows ( );
cout << "Update customer Streaming Direct to Direct
Sports" << endl;
database->updateField ( "Direct Sports" , "1193" );
cout << "Display invoice number, date, and updated
customer name" << endl;
database->displayAllRows ( );
cout << "Update customer Direct Sports to Streaming
Direct" << endl;
database->updateField ( "Streaming Direct" , "1193" );
cout << "Display invoice number, date, and updated
customer name" << endl;
database->displayAllRows ( );
delete database;
cout << "OCCI query and update completen" << endl;
system ( "pause" );
}
Part B:
Procedure:
Be sure to have a copy of the C++ to ProInsertExample code
presented in the Appendix B below.
Modify the member function in the ProInsertExample.cpp file
below to insert a new row in the Line table. Add the following
row: Invoice number: 42447, product ID: KW114, number
ordered: 1, and price: $595.00. Be sure to update the column
headings. Update the spacing between columns if necessary.
Modify the member function that deletes this new row inserted
in step 3 above. Display the contents of the Line table again.
Print out a copy of your output that displays the Line table
before the insertion, of the Line table after the insertion, and
the Line table after the deletion.
Submit a cover sheet, a copy of your output, and the source
code that you used to obtain it. Follow any additional
instructions that your instructor may give you.
Appendix B
/*
* Name: ProInsertExample.cpp
*
* Description:
* This source file inserts and deletes a row in the product
table.
* In addition the displayAllRows member function is
modified to display
* the contents of the product table.
*
* Remarks:
* Author Date Comment
* Mike Lukens 08/08/2008 initial code
*
*/
#include
#include
#include
using namespace oracle::occi;
using namespace std;
class occiIntf
{
public:
//constructor
occiIntf ( string login, string password, string dbStr )
{
//create an environment which Oracle requires
environ = Environment::createEnvironment (
Environment::DEFAULT );
try
{
//create a connection to the database
connect = environ->createConnection ( login,
password, dbStr );
}
catch ( SQLException excpt )
{
cout << "Exception thrown by createConnection"
<< endl;
cout << "Error code: "<< excpt.getErrorCode ( ) <<
endl;
cout << excpt.getMessage ( ) << endl;
system ( "pause" );
exit ( 1 );
}
}
//destructor
~occiIntf ( )
{
// Make sure to clean up the connection and the
environment when we are done!
environ->terminateConnection ( connect );
Environment::terminateEnvironment ( environ );
}
//update the customer name field
void updateField ( string name, string id )
{
//change the customer name in CUSTOMER table
string sqlStatmt
= "UPDATE customer SET cust_name = :x WHERE
cust_id = :y";
statmt = connect->createStatement ( sqlStatmt );
try
{
//substitute the customer name and id into the SQL
statement
statmt->setString ( 1, name );
statmt->setString ( 2, id );
statmt->executeUpdate ();
cout << "Update succeededn" << endl;
}
catch ( SQLException excpt )
{
cout << "Exception thrown by updateRow" << endl;
cout << "Error code: "<< excpt.getErrorCode ( ) <<
endl;
cout << excpt.getMessage ( ) << endl;
}
connect->terminateStatement ( statmt );
}
//display the product table
void displayAllRows ( )
{
//generate the SQL string
string sqlStatmt = "SELECT * FROM product";
//instantiate the statement object from our connection
object
//using the SQL string to initialize the statement
statmt = connect->createStatement ( sqlStatmt );
try
{
//execute the query and point to the result set in
order to
//loop through the returned data
ResultSet * resSet = statmt->executeQuery ( );
//display the column headers
cout << endl
<< setw ( 7 ) << "PROD ID" << " "
<< setw ( 20 ) << "PROD DESC" << " "
<< setw ( 3 ) << "#" << " "
<< setw ( 4 ) << "TYPE" << " "
<< setw ( 9 ) << "WAREHOUSE" << " "
<< setw ( 8 ) << "PRICE" << endl;
//keep processing the records until there are none
while ( resSet->next ( ) )
{
//get the attribute values either as strings or as
integers
cout << setw ( 7 ) << right << resSet->getString
( 1 ) << " "
<< setw ( 20 ) << resSet->getString ( 2 ) <<
" "
<< setw ( 3 ) << resSet->getInt ( 3 ) << " "
<< setw ( 4 ) << resSet->getString ( 4 ) <<
" "
<< setw ( 9 ) << resSet->getString ( 5 ) <<
" "
<< setw ( 8 ) << resSet->getFloat ( 6 ) << "
"
<< endl;
}
cout << endl;
//close the result set object
statmt->closeResultSet ( resSet );
}
catch ( SQLException excpt )
{
cout << "Exception thrown by displayAllRows" <<
endl;
cout << "Error code: " << excpt.getErrorCode ( ) <<
endl;
cout << excpt.getMessage ( ) << endl;
}
//close the statement
connect->terminateStatement ( statmt );
}
//insert a row into the product table
void insertRow ( )
{
//generate a string containing the SQL statement
string sqlStatmt =
"INSERT INTO PRODUCT VALUES ( 'MK140',
'Hair Trimmer', 23, 'AP', 'B', 19.95 )";
//instantiate a statement object from our connection
object using
//the SQL string to initialize the statement
statmt = connect->createStatement ( sqlStatmt );
try{
//execute the SQL statement
statmt->executeUpdate ( );
cout << "Inserting a row into the PRODUCT table
was successfuln" << endl;
}
catch ( SQLException excpt )
{
cout << "Exception thrown by insertRow" << endl;
cout << "Error code: "<< excpt.getErrorCode ( ) <<
endl;
cout << excpt.getMessage ( ) << endl;
}
//close this statement object
connect->terminateStatement ( statmt );
}
//delete a row
void deleteRow ( string product_id )
{
//generate the SQL statement to delete a product row
string sqlStatmt = "DELETE FROM PRODUCT
WHERE PROD_ID = :x";
statmt = connect->createStatement ( sqlStatmt );
try
{
// Substitute the product id into the prepared
statement
statmt->setString ( 1, product_id );
statmt->executeUpdate ( );
cout << "Delete a product rown" << endl;
}
catch ( SQLException excpt )
{
cout << "Exception thrown by deleteRow" << endl;
cout << "Error code: "<< excpt.getErrorCode ( ) <<
endl;
cout << excpt.getMessage ( ) << endl;
}
connect->terminateStatement ( statmt );
}
private:
// Variables required to interact with Oracle
Environment * environ;
Connection * connect;
Statement * statmt;
}; // end of class occiIntf
int main (void)
{
string dbStr = "ECET450";
string login;
string password;
cout << "Enter your Oracle login: ";
cin >> login;
cout << "Enter your Oracle password: ";
cin >> password;
system ( "CLS" );
cout << "Perform an insertion and a deletion using OCCI"
<< endl;
//instantiate an occiIntf object
occiIntf * database = new occiIntf ( login, password, dbStr
);
cout << "Display PRODUCT table" << endl;
database->displayAllRows ( );
cout << "Insert a new row into the PRODUCT table" <<
endl;
database->insertRow ( );
cout << "Display product table with the new row" << endl;
database->displayAllRows ( );
cout << "Delete the new row from the PRODUCT table" <<
endl;
database->deleteRow ( "MK140" );
cout << "Display product table without the new row" <<
endl;
database->displayAllRows ( );
delete database;
cout << "OCCI insertion and deletion completen" << endl;
system ( "pause" );
}

More Related Content

Similar to Part APurposeThis laboratory provides some experience work.docx

Angular 2.0 - What to expect
Angular 2.0 - What to expectAngular 2.0 - What to expect
Angular 2.0 - What to expect
Allan Marques Baptista
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
leminhvuong
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
phanleson
 
Les09 Manipulating Data
Les09 Manipulating DataLes09 Manipulating Data
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
Dendi Riadi
 
I keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdfI keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdf
herminaherman
 
Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web Services
WSO2
 
Pl sql using_xml
Pl sql using_xmlPl sql using_xml
Pl sql using_xml
Nayana Arewar
 
Ensure code quality with vs2012
Ensure code quality with vs2012Ensure code quality with vs2012
Ensure code quality with vs2012
Sandeep Joshi
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
yash production
 
JDBC Tutorial
JDBC TutorialJDBC Tutorial
JDBC Tutorial
Information Technology
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
kinan keshkeh
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIR
Peter Elst
 
Idoc script beginner guide
Idoc script beginner guide Idoc script beginner guide
Idoc script beginner guide
Vinay Kumar
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data Pipelines
HostedbyConfluent
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
RehmanRasheed3
 
IBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesIBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql Features
Keshav Murthy
 
70562-Dumps
70562-Dumps70562-Dumps
70562-Dumps
Pragya Rastogi
 
Relay Modern: architecture and workflow
Relay Modern: architecture and workflowRelay Modern: architecture and workflow
Relay Modern: architecture and workflow
Alex Alexeev
 
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docx
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docxAss2-Descriptor.docx1 Problem DescriptionThe objective of .docx
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docx
fredharris32
 

Similar to Part APurposeThis laboratory provides some experience work.docx (20)

Angular 2.0 - What to expect
Angular 2.0 - What to expectAngular 2.0 - What to expect
Angular 2.0 - What to expect
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
 
Les09 Manipulating Data
Les09 Manipulating DataLes09 Manipulating Data
Les09 Manipulating Data
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
I keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdfI keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdf
 
Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web Services
 
Pl sql using_xml
Pl sql using_xmlPl sql using_xml
Pl sql using_xml
 
Ensure code quality with vs2012
Ensure code quality with vs2012Ensure code quality with vs2012
Ensure code quality with vs2012
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
JDBC Tutorial
JDBC TutorialJDBC Tutorial
JDBC Tutorial
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIR
 
Idoc script beginner guide
Idoc script beginner guide Idoc script beginner guide
Idoc script beginner guide
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data Pipelines
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
IBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesIBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql Features
 
70562-Dumps
70562-Dumps70562-Dumps
70562-Dumps
 
Relay Modern: architecture and workflow
Relay Modern: architecture and workflowRelay Modern: architecture and workflow
Relay Modern: architecture and workflow
 
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docx
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docxAss2-Descriptor.docx1 Problem DescriptionThe objective of .docx
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docx
 

More from dewhirstichabod

CASE STUDY 2.1 W. L. Gore and AssociatesHe was ready for anythi.docx
CASE STUDY 2.1 W. L. Gore and AssociatesHe was ready for anythi.docxCASE STUDY 2.1 W. L. Gore and AssociatesHe was ready for anythi.docx
CASE STUDY 2.1 W. L. Gore and AssociatesHe was ready for anythi.docx
dewhirstichabod
 
Case Study 1Case Study 1Ms. A. is an apparently heal.docx
Case Study 1Case Study 1Ms. A. is an apparently heal.docxCase Study 1Case Study 1Ms. A. is an apparently heal.docx
Case Study 1Case Study 1Ms. A. is an apparently heal.docx
dewhirstichabod
 
Case study 1Client ProfileMrs. Harriet is a 68-year-old .docx
Case study 1Client ProfileMrs. Harriet is a 68-year-old .docxCase study 1Client ProfileMrs. Harriet is a 68-year-old .docx
Case study 1Client ProfileMrs. Harriet is a 68-year-old .docx
dewhirstichabod
 
Case Study 11.1 Why the Circus No Longer Comes to TownFor 146 y.docx
Case Study 11.1 Why the Circus No Longer Comes to TownFor 146 y.docxCase Study 11.1 Why the Circus No Longer Comes to TownFor 146 y.docx
Case Study 11.1 Why the Circus No Longer Comes to TownFor 146 y.docx
dewhirstichabod
 
Case Study 10.3 Regulating Love at the OfficeThe office has bec.docx
Case Study 10.3 Regulating Love at the OfficeThe office has bec.docxCase Study 10.3 Regulating Love at the OfficeThe office has bec.docx
Case Study 10.3 Regulating Love at the OfficeThe office has bec.docx
dewhirstichabod
 
Case Study 1 Is Business Ready for Wearable ComputersWearable .docx
Case Study 1 Is Business Ready for Wearable ComputersWearable .docxCase Study 1 Is Business Ready for Wearable ComputersWearable .docx
Case Study 1 Is Business Ready for Wearable ComputersWearable .docx
dewhirstichabod
 
Case Study 1 Headaches Neurological system and continue practicing .docx
Case Study 1 Headaches Neurological system and continue practicing .docxCase Study 1 Headaches Neurological system and continue practicing .docx
Case Study 1 Headaches Neurological system and continue practicing .docx
dewhirstichabod
 
CASE STUDY 1 HeadachesA 20-year-old male complains of exper.docx
CASE STUDY 1 HeadachesA 20-year-old male complains of exper.docxCASE STUDY 1 HeadachesA 20-year-old male complains of exper.docx
CASE STUDY 1 HeadachesA 20-year-old male complains of exper.docx
dewhirstichabod
 
Case Study - Stambovsky v. Ackley and Ellis Realty Supreme C.docx
Case Study - Stambovsky v. Ackley and Ellis Realty Supreme C.docxCase Study - Stambovsky v. Ackley and Ellis Realty Supreme C.docx
Case Study - Stambovsky v. Ackley and Ellis Realty Supreme C.docx
dewhirstichabod
 
CASE STUDY - THE SOCIAL NETWORKThe growing use of social network.docx
CASE STUDY - THE SOCIAL NETWORKThe growing use of social network.docxCASE STUDY - THE SOCIAL NETWORKThe growing use of social network.docx
CASE STUDY - THE SOCIAL NETWORKThe growing use of social network.docx
dewhirstichabod
 
Case Study #1 Probation or PrisonWrite a 12 to one page (.docx
Case Study #1 Probation or PrisonWrite a 12 to one page (.docxCase Study #1 Probation or PrisonWrite a 12 to one page (.docx
Case Study #1 Probation or PrisonWrite a 12 to one page (.docx
dewhirstichabod
 
Case Studies of Data Warehousing FailuresFour studies of data .docx
Case Studies of Data Warehousing FailuresFour studies of data .docxCase Studies of Data Warehousing FailuresFour studies of data .docx
Case Studies of Data Warehousing FailuresFour studies of data .docx
dewhirstichabod
 
Case Studies GuidelinesWhat is a Case StudyCase studies.docx
Case Studies GuidelinesWhat is a Case StudyCase studies.docxCase Studies GuidelinesWhat is a Case StudyCase studies.docx
Case Studies GuidelinesWhat is a Case StudyCase studies.docx
dewhirstichabod
 
Case Studies Focusing on Fluency StrategiesCase Scenario .docx
Case Studies Focusing on Fluency StrategiesCase Scenario .docxCase Studies Focusing on Fluency StrategiesCase Scenario .docx
Case Studies Focusing on Fluency StrategiesCase Scenario .docx
dewhirstichabod
 
Case Project 8-2 Detecting Unauthorized ApplicationsIn conducti.docx
Case Project 8-2 Detecting Unauthorized ApplicationsIn conducti.docxCase Project 8-2 Detecting Unauthorized ApplicationsIn conducti.docx
Case Project 8-2 Detecting Unauthorized ApplicationsIn conducti.docx
dewhirstichabod
 
Case Number 7Student’s NameInstitution Affiliation.docx
Case Number 7Student’s NameInstitution Affiliation.docxCase Number 7Student’s NameInstitution Affiliation.docx
Case Number 7Student’s NameInstitution Affiliation.docx
dewhirstichabod
 
Case number #10 OVERVIEWAbstract In this case, a local chapt.docx
Case number #10 OVERVIEWAbstract In this case, a local chapt.docxCase number #10 OVERVIEWAbstract In this case, a local chapt.docx
Case number #10 OVERVIEWAbstract In this case, a local chapt.docx
dewhirstichabod
 
Case GE’s Two-Decade Transformation Jack Welch’s Leadership.docx
Case GE’s Two-Decade Transformation Jack Welch’s Leadership.docxCase GE’s Two-Decade Transformation Jack Welch’s Leadership.docx
Case GE’s Two-Decade Transformation Jack Welch’s Leadership.docx
dewhirstichabod
 
CASE BRIEF 7.2 Tiffany and Company v. Andrew 2012 W.docx
CASE BRIEF 7.2  Tiffany and Company v. Andrew 2012 W.docxCASE BRIEF 7.2  Tiffany and Company v. Andrew 2012 W.docx
CASE BRIEF 7.2 Tiffany and Company v. Andrew 2012 W.docx
dewhirstichabod
 
CASE 5Business Performance Evaluation Approaches for Thoughtf.docx
CASE 5Business Performance Evaluation Approaches for Thoughtf.docxCASE 5Business Performance Evaluation Approaches for Thoughtf.docx
CASE 5Business Performance Evaluation Approaches for Thoughtf.docx
dewhirstichabod
 

More from dewhirstichabod (20)

CASE STUDY 2.1 W. L. Gore and AssociatesHe was ready for anythi.docx
CASE STUDY 2.1 W. L. Gore and AssociatesHe was ready for anythi.docxCASE STUDY 2.1 W. L. Gore and AssociatesHe was ready for anythi.docx
CASE STUDY 2.1 W. L. Gore and AssociatesHe was ready for anythi.docx
 
Case Study 1Case Study 1Ms. A. is an apparently heal.docx
Case Study 1Case Study 1Ms. A. is an apparently heal.docxCase Study 1Case Study 1Ms. A. is an apparently heal.docx
Case Study 1Case Study 1Ms. A. is an apparently heal.docx
 
Case study 1Client ProfileMrs. Harriet is a 68-year-old .docx
Case study 1Client ProfileMrs. Harriet is a 68-year-old .docxCase study 1Client ProfileMrs. Harriet is a 68-year-old .docx
Case study 1Client ProfileMrs. Harriet is a 68-year-old .docx
 
Case Study 11.1 Why the Circus No Longer Comes to TownFor 146 y.docx
Case Study 11.1 Why the Circus No Longer Comes to TownFor 146 y.docxCase Study 11.1 Why the Circus No Longer Comes to TownFor 146 y.docx
Case Study 11.1 Why the Circus No Longer Comes to TownFor 146 y.docx
 
Case Study 10.3 Regulating Love at the OfficeThe office has bec.docx
Case Study 10.3 Regulating Love at the OfficeThe office has bec.docxCase Study 10.3 Regulating Love at the OfficeThe office has bec.docx
Case Study 10.3 Regulating Love at the OfficeThe office has bec.docx
 
Case Study 1 Is Business Ready for Wearable ComputersWearable .docx
Case Study 1 Is Business Ready for Wearable ComputersWearable .docxCase Study 1 Is Business Ready for Wearable ComputersWearable .docx
Case Study 1 Is Business Ready for Wearable ComputersWearable .docx
 
Case Study 1 Headaches Neurological system and continue practicing .docx
Case Study 1 Headaches Neurological system and continue practicing .docxCase Study 1 Headaches Neurological system and continue practicing .docx
Case Study 1 Headaches Neurological system and continue practicing .docx
 
CASE STUDY 1 HeadachesA 20-year-old male complains of exper.docx
CASE STUDY 1 HeadachesA 20-year-old male complains of exper.docxCASE STUDY 1 HeadachesA 20-year-old male complains of exper.docx
CASE STUDY 1 HeadachesA 20-year-old male complains of exper.docx
 
Case Study - Stambovsky v. Ackley and Ellis Realty Supreme C.docx
Case Study - Stambovsky v. Ackley and Ellis Realty Supreme C.docxCase Study - Stambovsky v. Ackley and Ellis Realty Supreme C.docx
Case Study - Stambovsky v. Ackley and Ellis Realty Supreme C.docx
 
CASE STUDY - THE SOCIAL NETWORKThe growing use of social network.docx
CASE STUDY - THE SOCIAL NETWORKThe growing use of social network.docxCASE STUDY - THE SOCIAL NETWORKThe growing use of social network.docx
CASE STUDY - THE SOCIAL NETWORKThe growing use of social network.docx
 
Case Study #1 Probation or PrisonWrite a 12 to one page (.docx
Case Study #1 Probation or PrisonWrite a 12 to one page (.docxCase Study #1 Probation or PrisonWrite a 12 to one page (.docx
Case Study #1 Probation or PrisonWrite a 12 to one page (.docx
 
Case Studies of Data Warehousing FailuresFour studies of data .docx
Case Studies of Data Warehousing FailuresFour studies of data .docxCase Studies of Data Warehousing FailuresFour studies of data .docx
Case Studies of Data Warehousing FailuresFour studies of data .docx
 
Case Studies GuidelinesWhat is a Case StudyCase studies.docx
Case Studies GuidelinesWhat is a Case StudyCase studies.docxCase Studies GuidelinesWhat is a Case StudyCase studies.docx
Case Studies GuidelinesWhat is a Case StudyCase studies.docx
 
Case Studies Focusing on Fluency StrategiesCase Scenario .docx
Case Studies Focusing on Fluency StrategiesCase Scenario .docxCase Studies Focusing on Fluency StrategiesCase Scenario .docx
Case Studies Focusing on Fluency StrategiesCase Scenario .docx
 
Case Project 8-2 Detecting Unauthorized ApplicationsIn conducti.docx
Case Project 8-2 Detecting Unauthorized ApplicationsIn conducti.docxCase Project 8-2 Detecting Unauthorized ApplicationsIn conducti.docx
Case Project 8-2 Detecting Unauthorized ApplicationsIn conducti.docx
 
Case Number 7Student’s NameInstitution Affiliation.docx
Case Number 7Student’s NameInstitution Affiliation.docxCase Number 7Student’s NameInstitution Affiliation.docx
Case Number 7Student’s NameInstitution Affiliation.docx
 
Case number #10 OVERVIEWAbstract In this case, a local chapt.docx
Case number #10 OVERVIEWAbstract In this case, a local chapt.docxCase number #10 OVERVIEWAbstract In this case, a local chapt.docx
Case number #10 OVERVIEWAbstract In this case, a local chapt.docx
 
Case GE’s Two-Decade Transformation Jack Welch’s Leadership.docx
Case GE’s Two-Decade Transformation Jack Welch’s Leadership.docxCase GE’s Two-Decade Transformation Jack Welch’s Leadership.docx
Case GE’s Two-Decade Transformation Jack Welch’s Leadership.docx
 
CASE BRIEF 7.2 Tiffany and Company v. Andrew 2012 W.docx
CASE BRIEF 7.2  Tiffany and Company v. Andrew 2012 W.docxCASE BRIEF 7.2  Tiffany and Company v. Andrew 2012 W.docx
CASE BRIEF 7.2 Tiffany and Company v. Andrew 2012 W.docx
 
CASE 5Business Performance Evaluation Approaches for Thoughtf.docx
CASE 5Business Performance Evaluation Approaches for Thoughtf.docxCASE 5Business Performance Evaluation Approaches for Thoughtf.docx
CASE 5Business Performance Evaluation Approaches for Thoughtf.docx
 

Recently uploaded

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 

Recently uploaded (20)

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 

Part APurposeThis laboratory provides some experience work.docx

  • 1. Part A: Purpose: This laboratory provides some experience working with the C++ programming language that has an SQL query and SQL update embedded in it. Procedure: Follow the instructions below. Be sure to load the C++ to ProQueryExample code presented in the Appendix A below. In your ProQueryExample.cpp source file, modify the source code so that it changes the customer balance of Streaming Direct from $210.40 to $337.26. Rerun the query in step 3 above. Modify the source to return the balance of Streaming Direct to $210.40. Rerun the query in step 3 above. Print out a copy of your output. Submit a cover sheet, a copy of your output, and the source code that you used to obtain it. Follow any additional instructions that your instructor may give you. Appendix A /* * Name: ProQueryExample.cpp * * Description * This source code displays a join of the invoice and * customer tables. In addition this source code updates the
  • 2. Streaming * Direct customer name to Direct Sports and then returns the name back * to Streaming Direct. * * Remarks: * Author Date Comment * Mike Lukens 08/08/2008 initial code * */ #include #include #include using namespace oracle::occi; using namespace std; class occiIntf { public: //constructor occiIntf ( string login, string password, string dbStr ) { //setup the environment which Oracle requires environ = Environment::createEnvironment ( Environment::DEFAULT ); try { //create a connection to the database connect = environ->createConnection ( login, password, dbStr ); } catch ( SQLException excpt ) { cout << "Exception thrown by createConnection" << endl; cout << "Error code: "<< excpt.getErrorCode ( ) <<
  • 3. endl; cout << excpt.getMessage ( ) << endl; system ( "pause" ); exit ( 1 ); } } //destructor ~occiIntf ( ) { //make sure to clean up the connection and the environment when //we are done! environ->terminateConnection ( connect ); Environment::terminateEnvironment ( environ ); } //update a field void updateField ( string name, string id ) { //change the customer name to/from Direct Sports in CUSTOMER table string sqlStatmt = "UPDATE customer SET cust_name = :x WHERE cust_id = :y"; statmt = connect->createStatement ( sqlStatmt ); try { //substitute the customer name and id into the SQL statement statmt->setString ( 1, name ); statmt->setString ( 2, id ); statmt->executeUpdate (); cout << "Update succeededn" << endl; } catch ( SQLException excpt )
  • 4. { cout << "Exception thrown by updateField" << endl; cout << "Error code: "<< excpt.getErrorCode ( ) << endl; cout << excpt.getMessage ( ) << endl; } connect->terminateStatement ( statmt ); } //display the invoice number, date, and customer name void displayAllRows ( ) { //create the SQL statement string sqlStatmt = "SELECT invoice_num, invoice_date, cust_name FROM invoice, customer WHERE invoice.cust_id = customer.cust_id"; //instantiate the statement object from our connection object //using the SQL string to initialize the statement statmt = connect->createStatement ( sqlStatmt ); try { //execute the query and point to the result set //in order to loop through the returned data. ResultSet *resSet = statmt->executeQuery ( ); //display the column headers cout << endl << setw ( 5 ) << "INV #" << " " << setw ( 9 ) << "DATE " << " " << setw ( 20 ) << "CUSTOMER NAME" << endl; //keep getting results until there are none while ( resSet->next ( ) ) { //extract each attribute value which is a string
  • 5. cout << setw ( 5 ) << right << resSet->getString ( 1 ) << " " << setw ( 9 ) << resSet->getString ( 2 ) << " " << setw ( 30 ) << left << resSet->getString ( 3 ) << endl; } cout << endl; //close the result set object when done statmt->closeResultSet ( resSet ); } catch ( SQLException excpt ) { cout << "Exception thrown by displayAllRows." << endl; cout << "Error code: " << excpt.getErrorCode ( ) << endl; cout << excpt.getMessage ( ) << endl; } //done with statement connect->terminateStatement ( statmt ); } private: //variables required by OCCI Environment * environ; Connection * connect; Statement * statmt; }; //end of occiIntf class void main ( ) { string dbStr = "ECET450"; string login; string password;
  • 6. cout << "Enter your Oracle login: "; cin >> login; cout << "Enter your Oracle password: "; cin >> password; system ( "CLS" ); //clear the screen cout << "Demonstration of a query using OCCI" << endl; // First create an object that is connected with the Oracle database. occiIntf * database = new occiIntf ( login, password, dbStr ); cout << "Display invoice number, date, and customer name" << endl; database->displayAllRows ( ); cout << "Update customer Streaming Direct to Direct Sports" << endl; database->updateField ( "Direct Sports" , "1193" ); cout << "Display invoice number, date, and updated customer name" << endl; database->displayAllRows ( ); cout << "Update customer Direct Sports to Streaming Direct" << endl; database->updateField ( "Streaming Direct" , "1193" ); cout << "Display invoice number, date, and updated customer name" << endl; database->displayAllRows ( ); delete database; cout << "OCCI query and update completen" << endl; system ( "pause" ); }
  • 7. Part B: Procedure: Be sure to have a copy of the C++ to ProInsertExample code presented in the Appendix B below. Modify the member function in the ProInsertExample.cpp file below to insert a new row in the Line table. Add the following row: Invoice number: 42447, product ID: KW114, number ordered: 1, and price: $595.00. Be sure to update the column headings. Update the spacing between columns if necessary. Modify the member function that deletes this new row inserted in step 3 above. Display the contents of the Line table again. Print out a copy of your output that displays the Line table before the insertion, of the Line table after the insertion, and the Line table after the deletion. Submit a cover sheet, a copy of your output, and the source code that you used to obtain it. Follow any additional instructions that your instructor may give you. Appendix B /* * Name: ProInsertExample.cpp * * Description: * This source file inserts and deletes a row in the product table. * In addition the displayAllRows member function is modified to display * the contents of the product table.
  • 8. * * Remarks: * Author Date Comment * Mike Lukens 08/08/2008 initial code * */ #include #include #include using namespace oracle::occi; using namespace std; class occiIntf { public: //constructor occiIntf ( string login, string password, string dbStr ) { //create an environment which Oracle requires environ = Environment::createEnvironment ( Environment::DEFAULT ); try { //create a connection to the database connect = environ->createConnection ( login, password, dbStr ); } catch ( SQLException excpt ) { cout << "Exception thrown by createConnection" << endl; cout << "Error code: "<< excpt.getErrorCode ( ) << endl; cout << excpt.getMessage ( ) << endl; system ( "pause" ); exit ( 1 );
  • 9. } } //destructor ~occiIntf ( ) { // Make sure to clean up the connection and the environment when we are done! environ->terminateConnection ( connect ); Environment::terminateEnvironment ( environ ); } //update the customer name field void updateField ( string name, string id ) { //change the customer name in CUSTOMER table string sqlStatmt = "UPDATE customer SET cust_name = :x WHERE cust_id = :y"; statmt = connect->createStatement ( sqlStatmt ); try { //substitute the customer name and id into the SQL statement statmt->setString ( 1, name ); statmt->setString ( 2, id ); statmt->executeUpdate (); cout << "Update succeededn" << endl; } catch ( SQLException excpt ) { cout << "Exception thrown by updateRow" << endl; cout << "Error code: "<< excpt.getErrorCode ( ) << endl; cout << excpt.getMessage ( ) << endl; }
  • 10. connect->terminateStatement ( statmt ); } //display the product table void displayAllRows ( ) { //generate the SQL string string sqlStatmt = "SELECT * FROM product"; //instantiate the statement object from our connection object //using the SQL string to initialize the statement statmt = connect->createStatement ( sqlStatmt ); try { //execute the query and point to the result set in order to //loop through the returned data ResultSet * resSet = statmt->executeQuery ( ); //display the column headers cout << endl << setw ( 7 ) << "PROD ID" << " " << setw ( 20 ) << "PROD DESC" << " " << setw ( 3 ) << "#" << " " << setw ( 4 ) << "TYPE" << " " << setw ( 9 ) << "WAREHOUSE" << " " << setw ( 8 ) << "PRICE" << endl; //keep processing the records until there are none while ( resSet->next ( ) ) { //get the attribute values either as strings or as integers cout << setw ( 7 ) << right << resSet->getString ( 1 ) << " " << setw ( 20 ) << resSet->getString ( 2 ) << " " << setw ( 3 ) << resSet->getInt ( 3 ) << " "
  • 11. << setw ( 4 ) << resSet->getString ( 4 ) << " " << setw ( 9 ) << resSet->getString ( 5 ) << " " << setw ( 8 ) << resSet->getFloat ( 6 ) << " " << endl; } cout << endl; //close the result set object statmt->closeResultSet ( resSet ); } catch ( SQLException excpt ) { cout << "Exception thrown by displayAllRows" << endl; cout << "Error code: " << excpt.getErrorCode ( ) << endl; cout << excpt.getMessage ( ) << endl; } //close the statement connect->terminateStatement ( statmt ); } //insert a row into the product table void insertRow ( ) { //generate a string containing the SQL statement string sqlStatmt = "INSERT INTO PRODUCT VALUES ( 'MK140', 'Hair Trimmer', 23, 'AP', 'B', 19.95 )"; //instantiate a statement object from our connection object using //the SQL string to initialize the statement statmt = connect->createStatement ( sqlStatmt ); try{
  • 12. //execute the SQL statement statmt->executeUpdate ( ); cout << "Inserting a row into the PRODUCT table was successfuln" << endl; } catch ( SQLException excpt ) { cout << "Exception thrown by insertRow" << endl; cout << "Error code: "<< excpt.getErrorCode ( ) << endl; cout << excpt.getMessage ( ) << endl; } //close this statement object connect->terminateStatement ( statmt ); } //delete a row void deleteRow ( string product_id ) { //generate the SQL statement to delete a product row string sqlStatmt = "DELETE FROM PRODUCT WHERE PROD_ID = :x"; statmt = connect->createStatement ( sqlStatmt ); try { // Substitute the product id into the prepared statement statmt->setString ( 1, product_id ); statmt->executeUpdate ( ); cout << "Delete a product rown" << endl; } catch ( SQLException excpt ) { cout << "Exception thrown by deleteRow" << endl; cout << "Error code: "<< excpt.getErrorCode ( ) << endl;
  • 13. cout << excpt.getMessage ( ) << endl; } connect->terminateStatement ( statmt ); } private: // Variables required to interact with Oracle Environment * environ; Connection * connect; Statement * statmt; }; // end of class occiIntf int main (void) { string dbStr = "ECET450"; string login; string password; cout << "Enter your Oracle login: "; cin >> login; cout << "Enter your Oracle password: "; cin >> password; system ( "CLS" ); cout << "Perform an insertion and a deletion using OCCI" << endl; //instantiate an occiIntf object occiIntf * database = new occiIntf ( login, password, dbStr ); cout << "Display PRODUCT table" << endl; database->displayAllRows ( ); cout << "Insert a new row into the PRODUCT table" << endl; database->insertRow ( );
  • 14. cout << "Display product table with the new row" << endl; database->displayAllRows ( ); cout << "Delete the new row from the PRODUCT table" << endl; database->deleteRow ( "MK140" ); cout << "Display product table without the new row" << endl; database->displayAllRows ( ); delete database; cout << "OCCI insertion and deletion completen" << endl; system ( "pause" ); }