使用OCCI遇到的几个问题

来源:互联网 发布:人工神经网络知乎 编辑:程序博客网 时间:2024/05/17 23:13
1
调用hd->bindString(1, "001");
列或参数的位置无效

原来是因为
要先调用
string sql = "insert into userinfo_n ( id, name, address, telephone) values (:1, :2, :3, :4)";
hd->setSQL(sql);

2
hd->bindString(1, "001");
hd->bindString(2, "hai");
hd->bindString(3, "fei feng shan");
hd->bindInt(4, 1);


if(hd->executeUpdate() )
cout<<"Update success!\n"<<endl;
执行成功
SQL Developer里仍看不到数据

原来是因为
最后没有调用
hd->terminateStatement();
hd->disconnect();

注意:
在oracle官方站点上
http://docs.oracle.com/cd/B10501_01/appdev.920/a96583/cciaadem.htm

 /**   * updating a row   */  void updateRow ()   throw (SQLException)  {    cout << "Upadating record (Changing name,teammate and course_id)" << endl;    string sqlStmt =      "UPDATE foreign_student_tab SET name=:x, teammate=:y, course_id=:z";    Statement *stmt = con->createStatement (sqlStmt);    string fs_name = "jeffree";    Ref< person_typ > fs_teammate = getRefObj(       "SELECT REF(a) FROM person_tab a where name='jill'");    Number fs_course_id(5000);    stmt->setString(1, fs_name);    stmt->setRef(2,fs_teammate);    stmt->setInt(3, fs_course_id);    stmt->executeUpdate ();    con->commit();    con->terminateStatement (stmt);    cout << "Updation Successful" << endl;  }// end of updateRow (int, string);

这里调用了commit


原创粉丝点击