int Statement::setBindNullAtPos(int bindIx, int position, bool null) //position starts at 1. { if(null){ return OCI_BindSetNullAtPos(OCI_GetBind(ociStmt, bindIx), position); }else{ return OCI_BindSetNotNullAtPos(OCI_GetBind(ociStmt, bindIx), position); } }
void Statement::printBindVars() { int bindCount=OCI_GetBindCount(ociStmt); for(int i=1; i<=bindCount; ++i){ OCI_Bind *bind=OCI_GetBind(ociStmt, i); qDebug() << "Bind var name =" << OCI_BindGetName(bind) << ", type =" << OCI_BindGetType(bind) << ", data count =" << OCI_BindGetDataCount(bind); } }
int main(void) { OCI_Connection *cn; OCI_Statement *st; int i; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); st = OCI_StatementCreate(cn); OCI_SetBindAllocation(st, OCI_BAM_INTERNAL); OCI_Prepare(st, "insert into test_array values (:tab)"); OCI_BindArraySetSize(st, NB_ELEMS); OCI_BindArrayOfDates(st, ":tab", NULL, 0); { OCI_Date ** tab = (OCI_Date **) OCI_BindGetData(OCI_GetBind(st, 1)); for (i=0; i < NB_ELEMS; i++) { OCI_DateSysDate(tab[i]); } OCI_Execute(st); } OCI_Commit(cn); OCI_Cleanup(); return EXIT_SUCCESS; }