- 论坛徽章:
- 0
|
求助OCI方面内容
我写的一段测试文件。你看看,可能有帮助。
#include <stdio.h>;
#include <oci.h>;
#include <iostream.h>;
#include <newsLogin.hh>;
void main(int argc, char* argv[])
{
sword status;
sb4 errcode;
text info[512];
text* username=(text*)"news";
text* password=(text*)"news";
text* server=(text*)"";
status=newsLogin_news(server,username,password);
if(status!=OCI_SUCCESS) {
printf("SrcLogin error.\n" ;
// exit(0);
}
OCIEnv *envhp;
OCIError *errhp;
OCIServer *srvhp;
OCISvcCtx *svchp;
OCISession *authp;
CLIENT *client; /* remote file operation */
char _text_string[48];
float _level_pos;
float _vert_pos;
int _history_idx=1234;
int _index=4;
OCIStmt *stmthp;
OCIBind *bndp1 = (OCIBind *)0;
OCIBind *bndp2 = (OCIBind *)0;
OCIDefine *defnp1 = (OCIDefine *)0;
OCIDefine *defnp2 = (OCIDefine *)0;
OCIDefine *defnp3 = (OCIDefine *)0;
text* s_st=(text*)"SELECT text_string,level_position,
vert_position FROM textingeosection WHERE his_stage_idx=:his_stage_id AND gsect_text_idx=:gsect_text_idx";
// allocate statement handle
status=OCIHandleAlloc((dvoid *) envhp,(dvoid **)&stmthp,
OCI_HTYPE_STMT,(size_t)0,(dvoid **)0);
// prepare statement
status=OCIStmtPrepare(stmthp,errhp,s_st,
(ub4)strlen((char *)s_st),
(ub4)OCI_NTV_SYNTAX,(ub4)OCI_DEFAULT);
// bind
status=OCIBindByName(stmthp,&bndp1,errhp,(text *)":his_stage_id",
-1,(dvoid *)&_history_idx,sizeof(_history_idx),SQLT_INT,(dvoid *)0,
(ub2 *)0,(ub2 *)0,(ub4)0,(ub4 *)0,OCI_DEFAULT);
status=OCIBindByName(stmthp,&bndp2,errhp,(text *)":gsect_text_idx",
-1,(dvoid *)&_index,sizeof(_index),SQLT_INT,(dvoid *)0,
(ub2 *)0,(ub2 *)0,(ub4)0,(ub4 *)0,OCI_DEFAULT);
ub4 ind[3];
ub2 rlen[3],rcode[3];
status=OCIDefineByPos(stmthp,&defnp1,errhp,1,(dvoid *)_text_string,
48,SQLT_STR,&ind[0],&rlen[0],&rcode[0],OCI_DEFAULT);
status=OCIDefineByPos(stmthp,&defnp2,errhp,2,(dvoid *)&_level_pos,
sizeof(_level_pos),SQLT_FLT,&ind[1],&rlen[1],&rcode[1],OCI_DEFAULT);
status=OCIDefineByPos(stmthp,&defnp3,errhp,3,(dvoid *)&_vert_pos,
sizeof(_vert_pos),SQLT_FLT,&ind[2],&rlen[2],&rcode[2],OCI_DEFAULT);
//execute
status=OCIStmtExecute(svchp,stmthp,errhp,(ub4)1,(ub4)0,
(CONST OCISnapshot *)NULL,(OCISnapshot *)NULL,OCI_DEFAULT);
OCIHandleFree((dvoid *)stmthp, (ub4) OCI_HTYPE_STMT);
cout<<"_text_string=="<<_text_string<<endl;
cout<<"_level_pos=="<<_level_pos<<endl;
cout<<"_vert_pos==="<<_vert_pos<<endl;
status=newsLogoff_news();
} |
|