Eg:单条查询
sql: select username,age from student where username=:p1;
如果此字段有可能有空值,则
hDefine = NULL;
swResult = OCIDefineByPos(stmtp &hDefine, errhp, 1, tstd.username, sizeof(tstd.username), SQLT_CHR, & sb2aInd[0], NULL, NULL, OCI_DEFAULT);
hDefine = NULL;
swResult = OCIDefineByPos(stmtp &hDefine, errhp, 1, tstd.username, sizeof(tstd.username), SQLT_CHR, NULL, NULL, NULL, OCI_DEFAULT);
批量查询
select username,age from student where age>30;
hDefine = NULL;
swResult = OCIDefineByPos(stmtp, &hDefine, errhp, 1, &tstd[0].username,
sizeof(tstd[0].usenmae), SQLT_CHR, NULL, NULL, NULL, OCI_DEFAULT);
swResult = OCIDefineArrayOfStruct(hDefine, errhp, sizeof(tstd[0]), 0, 0, 0);
11.提取结果
sword OCIStmtFetch (
OCIStmt *stmtp,//语句句柄
OCIError *errhp,
ub4 nrows, //从当前位置处开始一次提取的记录数,对于数据变量,可以>1,否则不能>1
ub2 orientation,//提取的方向:OCI_FETCH_NEXT
ub4 mode //OCI_DEFAULT
)






