SlideShare a Scribd company logo
1 of 14
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

Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commandsphanleson
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commandsleminhvuong
 
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.pdfherminaherman
 
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 ServicesWSO2
 
Ensure code quality with vs2012
Ensure code quality with vs2012Ensure code quality with vs2012
Ensure code quality with vs2012Sandeep Joshi
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaonyash production
 
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 overloadingkinan keshkeh
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIRPeter 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 PipelinesHostedbyConfluent
 
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 FeaturesKeshav Murthy
 
Relay Modern: architecture and workflow
Relay Modern: architecture and workflowRelay Modern: architecture and workflow
Relay Modern: architecture and workflowAlex 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 .docxfredharris32
 

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.docxdewhirstichabod
 
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.docxdewhirstichabod
 
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 .docxdewhirstichabod
 
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.docxdewhirstichabod
 
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.docxdewhirstichabod
 
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 .docxdewhirstichabod
 
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 .docxdewhirstichabod
 
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.docxdewhirstichabod
 
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.docxdewhirstichabod
 
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.docxdewhirstichabod
 
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 (.docxdewhirstichabod
 
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 .docxdewhirstichabod
 
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.docxdewhirstichabod
 
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 .docxdewhirstichabod
 
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.docxdewhirstichabod
 
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.docxdewhirstichabod
 
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.docxdewhirstichabod
 
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.docxdewhirstichabod
 
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.docxdewhirstichabod
 
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.docxdewhirstichabod
 

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

Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Recently uploaded (20)

Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

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