コード例 #1
0
ファイル: low_level_oracle.cpp プロジェクト: jrandall/irods
/*
  Return a row from a previous cllExecSqlWithResult call.
*/
int
cllGetRow( icatSessionStruct *icss, int statementNumber ) {
    static OCIStmt          *p_statement;
    int nCols, stat;

    icatStmtStrct *myStatement;

    myStatement = icss->stmtPtr[statementNumber];
    nCols = myStatement->numOfCols;
    p_statement = ( OCIStmt * )myStatement->stmtPtr;

    stat = OCIStmtFetch( p_statement, p_err, ( ub4 )1, ( ub2 )0,
                         ( ub4 ) OCI_DEFAULT );
    if ( stat != OCI_SUCCESS && stat != OCI_NO_DATA ) {
        logOraError( LOG_ERROR, p_err, stat );
        _cllFreeStatementColumns( icss, statementNumber );
        myStatement->numOfCols = 0;
        rodsLog( LOG_ERROR, "cllGetRow: Fetch failed: %d", stat );
        return -1;
    }
    if ( stat == OCI_SUCCESS ) {
        return 0;
    }
    _cllFreeStatementColumns( icss, statementNumber );
    myStatement->numOfCols = 0;
    return 0;
}
コード例 #2
0
ファイル: icatLowLevelOdbc.c プロジェクト: brandt/irods
/*
  Return a row from a previous cllExecSqlWithResult call.
 */
int
cllGetRow(icatSessionStruct *icss, int statementNumber) {
   HSTMT hstmt;
   RETCODE stat;
   int nCols, i;
   icatStmtStrct *myStatement;
   int logGetRows=0; /* Another handy debug flag.  When set and if
                        spLogSql is set, this function will log each
                        time a row is gotten, the number of columns ,
                        and the contents of the first column.  */

   myStatement=icss->stmtPtr[statementNumber];
   hstmt = myStatement->stmtPtr;
   nCols = myStatement->numOfCols;

   for (i=0;i<nCols;i++) {
      strcpy((char *)myStatement->resultValue[i],"");
   }
   stat =  SQLFetch(hstmt);
   if (stat != SQL_SUCCESS && stat != SQL_NO_DATA_FOUND) {
      rodsLog(LOG_ERROR, "cllGetRow: SQLFetch failed: %d", stat);
      return(-1);
   }
   if (stat == SQL_NO_DATA_FOUND) {
      if (logGetRows) {
	 char tmpstr[210];
	 snprintf(tmpstr, 200, "cllGetRow: NO DATA FOUND, statement:%d",
		  statementNumber);
	 rodsLogSql(tmpstr);
      }
      _cllFreeStatementColumns(icss,statementNumber);
      myStatement->numOfCols=0;
   }
   else {
      if (logGetRows) {
	 char tmpstr[210];
	 snprintf(tmpstr, 200, "cllGetRow statement:%d columns:%d first column: %s", 
		  statementNumber, nCols, 
		  myStatement->resultValue[0]);
	 rodsLogSql(tmpstr);
      }
   }
   return(0);
}