Logo Search packages:      
Sourcecode: maxdb-7.5.00 version File versions  Download package

tcn00_Error cn85DBFetchNice ( VControlDataT *  vcontrol,
CommandT *  command,
char *  replyData,
int *  replyLen,
int  replyLenMax 
)

cn85DBFetchNice

Fetch result from kernel task in "nice" answer format.

Definition at line 527 of file vcn85.cpp.

References Tools_DynamicUTF8String::CharPtr(), cn85GetKernelSession(), DBMSrv_SQLRecord::fieldAsChar(), DBMSrv_SQLRecord::fieldName(), DBMSrv_SQLRecord::fields(), DBMSrv_SQLRecord::getNextRecord(), and SAPDB_strcpy.

Referenced by cn85_DBExecute().

{
  tcn00_Error nFuncReturn = OK_CN00;
  bool        bTemporary  = false;

  nFuncReturn = cn85GetKernelSession(vcontrol, replyData, replyLen, bTemporary);

  if (nFuncReturn == OK_CN00) {

    DBMSrv_SQLRecord oRecord(*(vcontrol->pKernelSession));
    bool             bEnd      = false;
    bool             bContinue = false;

    cn90AnswerOK(replyData, replyLen, NULL);
    tsp00_Int4 i = 0;

    char * pCurrent  = replyData + strlen(replyData);
    char * pContinue = pCurrent;
    SAPDB_strcpy(pCurrent, CONTINUE_TXT);
    pCurrent  = pCurrent + strlen(pCurrent);


    for (i = 1; i <= oRecord.fields(); ++i) {
      sprintf(pCurrent, "%-30s = %s%s", oRecord.fieldName(i).CharPtr(), oRecord.fieldAsChar(i, STRINGMARK_CHAR).CharPtr(), LINE_SEPSTRING_CN00);
      pCurrent = pCurrent + strlen(pCurrent);
    } // end if

    *replyLen = (int) strlen(replyData);

    oRecord.getNextRecord(bEnd);

    if (!vcontrol->pKernelSession->LastMessage().IsEmpty()) {
      nFuncReturn = cn90AnswerMessage(replyData, replyLen, vcontrol->pKernelSession->LastMessage());
    } else {
      if (bEnd) {
        strncpy(pContinue, EMPTY_TXT, strlen(EMPTY_TXT));
      } else {
        // prepare next command 
        vcontrol->szNextCommand.rawAssign("db_fetchnice");
        vcontrol->nNextCommandSkip = 1;
      } // end if
    } // end if

    *replyLen = (int) strlen(replyData);

  } // end if

  return nFuncReturn;
} // end cn85DBFetchNice


Generated by  Doxygen 1.6.0   Back to index