You are on page 1of 3

#include <iostream> #include <occi.h> #include <stdio.

h> using namespace std; using namespace oracle::occi; class OracleConnection { private: string userName ; string password ; string database ; public: Environment *env; Connection *conn; OracleConnection(); ~OracleConnection(); }; OracleConnection::OracleConnection():userName("e684315"),password("30071991"),da tabase("oraconn") { env=Environment::createEnvironment(Environment::DEFAULT); conn=env->createConnection(userName,password,database); cout << "OCCI Environment and Connection Created " << endl; } OracleConnection::~OracleConnection() { conn->commit(); cout << "Terminating the Connection and Environment" << endl; env->terminateConnection(conn); Environment::terminateEnvironment(env); } class postplan { Statement *stmt; public: void addpostplan() { OracleConnection aConnection; stmt=aConnection.conn->createStatement(); int c1, c2, c3, c5, c6; string c4; cout<<endl; cout<<endl; cout<<'\t'<<"Enter planid : "; cin>>c1; cout<<'\t'<<"Enter speed : "; cin>>c2; cout<<'\t'<<"Enter rate : "; cin>>c3; cout<<'\t'<<"Enter plan_type : "; cin>>c4; cout<<'\t'<<"Enter instr_cost : "; cin>>c5; cout<<'\t'<<"Enter wired_inst_cst : "; cin>>c6; cout<<endl; cout<<endl; stmt->setSQL("insert into Postpaid_plan values(:1, :2, :3, :4, :5, :6)");

cout<<'\t'<<"--------------------Insert successful-----------------------"<<endl . stmt->setInt(6. postplan post."<<endl.stmt->setInt(1. aConnection.c5). } void view() { OracleConnection aConnection.c2). Update Postpaid Plan. c1 = rs->getInt(1). string c4. aConnection.c3). <<"Plan_type :" << c4 << endl. cout<<"1.conn->terminateStatement(stmt). //Print the 2'nd value <<"Rate :" << c3 << endl.conn->createStatement(). c6 = rs->getInt(6). cout<<endl.c3. stmt=aConnection. stmt->setInt(1. stmt->setInt(3."<<endl. stmt->setString(4. int c1. cout<<"2. c4 = rs->getString(4). cout<<"Enter your choice:"<<endl.c2.c6. } }. cout << "Selecting Records from Table " << endl. cout cout cout cout cout cout //get the 2'nd value //get the 3'nd value <<"Plan ID :" << c1 << endl. cid). stmt->setInt(2. stmt->setInt(5. c5 = rs->getInt(5). <<"Wired_inst_cost:" << c6 << endl.c4). int nFlag=stmt->executeUpdate(). cin>>cid. . View Postpaid Plan. int cid. Statement *stmt =aConnection. c3 = rs->getInt(3). <<"Instr_cost :" << c5 << endl.c5.c6).c1). //Print the 1'nd value <<"Speed :" << c2 << endl. int main() { int ans. cout<<"Enter plan id:"<<endl.conn->createStatement("SELECT * FROM postpaid_plan WHERE plan_id= :1"). //Selecting Records from Table rs->next(). ResultSet *rs = stmt->executeQuery(). c2 = rs->getInt(2).conn->terminateStatement(stmt). cout<<endl.

switch(ans) { case 1: { post.. Add Postpaid Plan. break.} case 2: { post. break.} } return 0. Delete Postpaid Plan."<<endl.view().} case 3: { post."<<endl.} case 4: { post.Update(). cout<<"4.. break.deleteplan()..cout<<"3. cin>>ans."<<endl.addpostplan().. cout<<".. } . break.