CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Oracle >  基础和管理

谁有OCI的资料阿?能不能给一点学习一下阿?

楼主Yans(跟贴是一种友谊)2005-03-03 23:14:31 在 Oracle / 基础和管理 提问

请大虾给点关于OCI的资料,并且给点例子给讲解一下!谢谢! 问题点数:20、回复次数:10Top

1 楼netcreator(爱博)回复于 2005-03-03 23:20:04 得分 5

oracle   connecting   interface吗?  
  好象是使用tcp/ip直接连接oracle   rdbms的概念,完全不用中间件和客户端,在任意直接winsock的机器上就可以访问oracle数据库的东东吗?  
  我用odac做过这样的程序,800K的客户端,拷在一张软盘上,随处都可以利用这个客户端对远程的ORACLE数据库进行完全访问。  
  好象用就用过,不过关于OCI的文档没有仔细研究,都是OO的东东,没有过那个细啊!  
  文档我都有,全是洋文的,想要的话联系我  
  我找找,然后放在我的网站上,自己去找并DOWN  
  http://javan.cn/Top

2 楼Yans(跟贴是一种友谊)回复于 2005-03-05 15:28:39 得分 0

谢谢,请发到我的邮箱:Toyan@163.netTop

3 楼masterz(www.fruitfruit.com)回复于 2005-03-05 16:53:42 得分 5

The   following   code   example   demonstrates   how   to   perform   simple   insert,   delete,  
  and   update   operations   on   a   table   column   of   type   Nested   Table:  
  /**  
  *occicoll   -   To   exhibit   simple   insert,   delete   &   update   operations"  
  *   "   on   table   having   a   Nested   Table   column  
  *  
  *Description  
  *   Create   a   program   which   has   insert,delete   and   update   on   a  
  *   table   having   a   Nested   table   column.  
  *   Perform   all   these   operations   using   OCCI   interface.  
  */  
  #include   <iostream.h>  
  #include   <occi.h>  
  using   namespace   oracle::occi;  
  using   namespace   std;  
  typedef   vector<string>   journal;  
  class   occicoll  
  {  
  private:  
  Environment   *env;  
  Connection   *conn;  
  Statement   *stmt;  
  string   tableName;  
  string   typeName;  
  public:  
  occicoll   (string   user,   string   passwd,   string   db)  
  {  
  env   =   Environment::createEnvironment   (Environment::OBJECT);  
  conn   =   env->createConnection   (user,   passwd,   db);  
  initRows();  
  }  
  ~occicoll   ()  
  {  
  env->terminateConnection   (conn);  
  Environment::terminateEnvironment   (env);  
  }  
  void   setTableName   (string   s)  
  {  
  tableName   =   s;  
  }  
  void   initRows   ()  
  {  
  try{  
  Statement   *st1   =   conn->createStatement   ("DELETE   FROM   journal_tab");  
  st1->executeUpdate   ();  
  st1->setSQL("INSERT   INTO   journal_tab   (jid,   jname)   VALUES   (22,   journal  
  ('NATION',   'TIMES'))");  
  st1->executeUpdate   ();  
  st1->setSQL("INSERT   INTO   journal_tab   (jid,   jname)   VALUES   (33,   journal  
  ('CRICKET',   'ALIVE'))");  
  st1->executeUpdate   ();  
  conn->commit();  
  conn->terminateStatement   (stmt);  
  }catch(SQLException   ex)  
  {  
  cout<<ex.what();  
  }  
  }  
  /**  
  *   Insertion   of   a   row  
  */  
  void   insertRow   ()  
  {  
  int   c1   =   11;  
  journal   c2;  
  c2.push_back   ("LIFE");  
  c2.push_back   ("TODAY");  
  c2.push_back   ("INVESTOR");  
  cout   <<   "Inserting   row   with   jid   =   "   <<   11   <<  
  "   and   journal_tab   (LIFE,   TODAY,   INVESTOR   )"   <<   endl;  
  try{  
  stmt   =   conn->createStatement   (  
  "INSERT   INTO   journal_tab   (jid,   jname)   VALUES   (:x,   :y)");  
  stmt->setInt   (1,   c1);  
  setVector   (stmt,   2,   c2,   "JOURNAL");  
  stmt->executeUpdate   ();  
  }catch(SQLException   ex)  
  {  
  cout<<"Exception   thrown   for   insertRow"<<endl;  
  cout<<"Error   number:   "<<   ex.getErrorCode()   <<   endl;  
  cout<<ex.getMessage()   <<   endl;  
  }  
  cout   <<   "Insertion   -   Successful"   <<   endl;  
  conn->terminateStatement   (stmt);  
  }  
  //   Displaying   all   the   rows   of   the   table  
  void   displayAllRows   ()  
  {  
  cout   <<   "Displaying   all   the   rows   of   the   table"   <<   endl;  
  stmt   =   conn->createStatement   (  
  "SELECT   jid,   jname   FROM   journal_tab");  
  journal   c2;  
  ResultSet   *rs   =   stmt->executeQuery();  
  try{  
  while   (rs->next())  
  {  
  cout   <<   "jid:   "   <<   rs->getInt(1)   <<   endl;  
  cout   <<   "jname:   ";  
  getVector   (rs,   2,   c2);  
  for   (int   i   =   0;   i   <   c2.size();   ++i)  
  cout   <<   c2[i]   <<   "   ";  
  cout   <<   endl;  
  }  
  }catch(SQLException   ex)  
  {  
  cout<<"Exception   thrown   for   displayRow"<<endl;  
  cout<<"Error   number:   "<<   ex.getErrorCode()   <<   endl;  
  cout<<ex.getMessage()   <<   endl;  
  }  
  stmt->closeResultSet   (rs);  
  conn->terminateStatement   (stmt);  
  }   //   End   of   displayAllRows()Top

4 楼masterz(www.fruitfruit.com)回复于 2005-03-05 16:54:03 得分 5

//   Deleting   a   row   in   a   nested   table  
  void   deleteRow   (int   c1,   string   str)  
  {  
  cout   <<   "Deleting   a   row   in   a   nested   table   of   strings"   <<   endl;  
  stmt   =   conn->createStatement   (  
  "SELECT   jname   FROM   journal_tab   WHERE   jid   =   :x");  
  journal   c2;  
  stmt->setInt   (1,   c1);  
  ResultSet   *rs   =   stmt->executeQuery();  
  try{  
  if   (rs->next())  
  {  
  getVector   (rs,   1,   c2);  
  c2.erase   (find   (c2.begin(),   c2.end(),   str));  
  }  
  stmt->setSQL   ("UPDATE   journal_tab   SET   jname   =   :x   WHERE   jid   =   :y");  
  stmt->setInt   (2,   c1);  
  setVector   (stmt,   1,   c2,   "JOURNAL");  
  stmt->executeUpdate   ();  
  }catch(SQLException   ex)  
  {  
  cout<<"Exception   thrown   for   delete   row"<<endl;  
  cout<<"Error   number:   "<<   ex.getErrorCode()   <<   endl;  
  cout<<ex.getMessage()   <<   endl;  
  }  
  cout   <<   "Deletion   -   Successful"   <<   endl;  
  conn->commit();  
  stmt->closeResultSet   (rs);  
  conn->terminateStatement   (stmt);  
  }   //   End   of   deleteRow   (int,   string)  
  //   Updating   a   row   of   the   nested   table   of   strings  
  void   updateRow   (int   c1,   string   str)  
  {  
  cout   <<   "Updating   a   row   of   the   nested   table   of   strings"   <<   endl;  
  stmt   =   conn->createStatement   (  
  "SELECT   jname   FROM   journal_tab   WHERE   jid   =   :x");  
  journal   c2;  
  stmt->setInt   (1,   c1);  
  ResultSet   *rs   =   stmt->executeQuery();  
   
  try{  
  if   (rs->next())  
  {  
  getVector   (rs,   1,   c2);  
  c2[0]   =   str;  
  }  
  stmt->setSQL   ("UPDATE   journal_tab   SET   jname   =   :x   WHERE   jid   =   :y");  
  stmt->setInt   (2,   c1);  
  setVector   (stmt,   1,   c2,   "JOURNAL");  
  stmt->executeUpdate   ();  
  }catch(SQLException   ex)  
  {  
  cout<<"Exception   thrown   for   updateRow"<<endl;  
  cout<<"Error   number:   "<<   ex.getErrorCode()   <<   endl;  
  cout<<ex.getMessage()   <<   endl;  
  }  
  cout   <<   "Updation   -   Successful"   <<   endl;  
  conn->commit();  
  stmt->closeResultSet   (rs);  
  conn->terminateStatement   (stmt);  
  }   //   End   of   UpdateRow   (int,   string)  
  };//end   of   class   occicoll  
  int   main   (void)  
  {  
  string   user   =   "SCOTT";  
  string   passwd   =   "TIGER";  
  string   db   =   "";  
  try  
  {  
  cout   <<   "occicoll   -   Exhibiting   simple   insert,   delete   &   update   operations"  
  "   on   table   having   a   Nested   Table   column"   <<   endl;  
  occicoll   *demo   =   new   occicoll   (user,   passwd,   db);  
  cout   <<   "Displaying   all   rows   before   the   operations"   <<   endl;  
  demo->displayAllRows   ();  
  demo->insertRow   ();  
  demo->deleteRow   (11,   "TODAY");  
  demo->updateRow   (33,   "New_String");  
  cout   <<   "Displaying   all   rows   after   all   the   operations"   <<   endl;  
  demo->displayAllRows   ();  
  delete   (demo);  
  cout   <<   "occicoll   -   done"   <<   endl;  
  }catch   (SQLException   ea)  
  {  
  cerr   <<   "Error   running   the   demo:   "   <<   ea.getMessage   ()   <<   endl;  
  }  
  }Top

5 楼masterz(www.fruitfruit.com)回复于 2005-03-05 16:56:52 得分 0

www.fruitfruit.com/oci9i.zipTop

6 楼Yans(跟贴是一种友谊)回复于 2005-03-06 21:31:49 得分 0

谢谢Top

7 楼allanyan(allan)回复于 2005-03-07 09:00:52 得分 5

推荐你用OTL(Oracle   Templete   Library)吧,很好用的!!  
  http://www.cnblogs.com/allanyan/articles/105159.htmlTop

8 楼Yans(跟贴是一种友谊)回复于 2005-04-30 21:47:22 得分 0

我用的是cb,该怎么用呢?Top

9 楼Yans(跟贴是一种友谊)回复于 2005-05-10 18:26:04 得分 0

upTop

10 楼Yans(跟贴是一种友谊)回复于 2005-05-15 11:00:53 得分 0

upTop

相关问题

  • vcl学习资料
  • vc学习资料
  • 谁有 BCB 学习资料?
  • 需vb学习资料!!!
  • 求VisualAge的学习资料
  • 求VisualAge的学习资料
  • 求VisualAge的学习资料
  • 求VisualAge的学习资料
  • 求VisualAge的学习资料
  • 求VisualAge的学习资料

关键词

  • 客户
  • stmt
  • journal
  • jname
  • terminatestatement
  • jid
  • displayallrows
  • occicoll
  • setsql
  • closeresultset

得分解答快速导航

  • 帖主:Yans
  • netcreator
  • masterz
  • masterz
  • allanyan

相关链接

  • Oracle类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo