达梦(5)通过DCI实现增删改查(三)
先要在数据库中存在这条记录 */
/************************************************************************/
memset(sql, 0, sizeof(sql));
strcpy(sql, "delete from person.person WHERE personid= ");
/* 准备SQL 语句 */
OCIStmtPrepare(stmthp, errhp,(text *)sql, strlen(sql),OCI_NTV_SYNTAX, OCI_DEFAULT);
/* 绑定输入参数 */
memset(szpersonid, 0, sizeof(szpersonid));
memcpy(szpersonid,"20",strlen("20")+1);
//strcpy(szpersonid, "20");
OCIBindByPos(stmthp, &bidhp[0], errhp, 1, szpersonid, sizeof(szpersonid),SQLT_AFC, NULL, NULL, NULL, 0, NULL, 0);
/* 执行SQL 语句 */
OCIStmtExecute(svchp, stmthp, errhp, (ub4)0, (ub4) 0, (CONST OCISnapshot*) 0, (OCISnapshot*) 0, (ub4) OCI_DEFAULT);
/* 提交到
数据库 */
OCITransCommit(svchp, errhp, OCI_DEFAULT);
// 结束会话
OCISessionEnd(svchp, errhp, authp, (ub4) 0);
// 断开与数据库的连接
OCIServerDetach(srvhp, errhp, OCI_DEFAULT);
// 释放OCI句柄
OCIHandleFree((dvoid*)dschp, OCI_HTYPE_DESCRIBE);
OCIHandleFree((dvoid*)stmthp, OCI_HTYPE_STMT );
OCIHandleFree((dvoid*)errhp, OCI_HTYPE_ERROR);
OCIHandleFree((dvoid*)authp, OCI_HTYPE_SESSION );
OCIHandleFree(( dvoid*)svchp, OCI_HTYPE_SVCCTX);
OCIHandleFree((dvoid*)srvhp, OCI_HTYPE_SERVER);
return 0;
}