OCCI 中文编程指南(19)

发布时间: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;

OCCI 中文编程指南(19).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219