手机版

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文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)