⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 records.cpp

📁 联通接收发送新程序
💻 CPP
字号:
static const char* sccsid = "@(#)records.cpp v1.0.0 2000-08-08";
/* Copyright(C) 1999, 2000 by JiangSu Bell Software CO.,LTD. */
/*
  Name: records.cpp                    Version: 1.0.0
  Created by HanBing                   Date: 2000-08-08
  Comment: Our group defining all base-class sets
  Modified:
1)  2000-08-08	HanBing	-	Create;
*/

#include "common.h"
#include "dbbase.h"

/*Following is implement class CRecords functions*/
CRecords :: CRecords( uint size, XW_Connection& conn )
{
  connect = &conn;
  BatSize = size;
  nRow = 0;
  nCol = 0;
//hyl on 20030922
  CurTotal = 0 ;
//
}

void CRecords :: Destroy()
{
  for ( uint i = 0; i < nCol; i++ )
    delete Fields[i];
  nCol = 0;
  nRow = 0;
}

CField& CRecords :: Field( const char *FieldName )
{
  uint j = 0;
  if ( FieldName && strlen( FieldName ) )
    for ( j = 0; j < nCol && strcmp( FieldName, Fields[j]->Name() ); j++ );
  return Field( j );
}

long CRecords :: Query( char *sql )
{
  Destroy();
  long j = -1;
  cursor.Open( connect );
  if ( cursor.IsOpen() )
  {
    if ( cursor.Parse( sql ) )
      j = cursor.Execute( BatSize );
    if ( j > 0 )
    {
      int k = cursor.Describe( nCol, Fields[ nCol ] );
      while ( k > 0 )
      {
        if ( !cursor.DefineCol( nCol, Fields[ nCol ] ) )
          k = -1;
        else
        {
          nCol += 1;
          k = cursor.Describe( nCol, Fields[ nCol ] );
        }
      }
      if ( k < 0 )
        j = -1;
    }
    if ( j > 0 )
      j = Next();
  }
  else
    cursor.ReportError();
  return j;
}

long CRecords :: Next()
{
//hyl on 20030922
  //static long CurTotal = 0;
//
  if ( nRow % BatSize != 0 && CurTotal > 0 && nRow < CurTotal )
  {
    for ( uint i = 0; i < nCol; i++ )
      Fields[i]->Next();
    nRow += 1;
  }
  else if ( nRow % BatSize == 0 && cursor.IsOpen() )
  {
    for ( uint i = 0; i < nCol; i++ )
      Fields[i]->Clear();
    CurTotal = cursor.Fetch( BatSize );
    if ( CurTotal > nRow )
      nRow += 1;
    else if ( CurTotal < 0 )
      nRow = CurTotal;
    else
      nRow = CurTotal = 0;
  }
  else
  {
    CurTotal = 0;
    nRow = 0;
  }
  return nRow;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -