OCCI 中文编程指南(19)
发布时间:2021-06-08
发布时间:2021-06-08
string username = "bill"; string password = "bill"; string connstring = "jftest"; string sql;
int isno[2]={21,22},i,iage[2]={18,19};
try {
env = Environment::createEnvironment();
conn = env->createConnection(username,password,connstring); stmt = conn->createStatement(); stmt->setAutoCommit(false);
sql = " merge into student a ";
sql += " using (select :x bid,:y bage from dual) b "; sql += " on (a.sno = b.bid) "; sql += " when matched then ";
sql += " update set a.age= a.age+b.bage "; sql += " when not matched then "; sql += " insert (a.sno,a.age) "; sql += " values (b.bid,b.bage) ";
stmt->setSQL(sql);
stmt->setMaxIterations(2);
stmt->setMaxParamSize(1,sizeof(int)); //stmt->setMaxParamSize(2,sizeof(string)); cout<<"setMaxIterations success !"<<endl;
//cout<<"getMaxIterations = "<<stmt->getMaxIterations()<<endl; for (i=0;i<2;i++) {
stmt->setInt(1,isno[i]); stmt->setInt(2,iage[i]);
if (i!=1) stmt->addIteration(); }
cout<<"getMaxParamSize = "<<stmt->getMaxParamSize(2)<<endl; cout<<"getMaxIterations = "<<stmt->getMaxIterations()<<endl; cout<<"set success"<<endl; stmt->executeUpdate(); //Ö´ÐÐSQLÓï¾ä conn->commit(); cout << "INSERT ¨D¨D SUCCESS" << endl;
上一篇:地理信息系统(gis)英语论文
下一篇:初中中学共青团团队工作计划,方案