CRecordset::FlushResultSet

BOOL FlushResultSet () const;
(CDBException)를 던져;

반환 값

0이 아닌 경우에 더 많은 결과 집합을 검색할 수; 그렇지 않으면 0。

주의

여러 결과 집합이 있는 경우 미리 정의 된 쿼리 (저장된 프로시저)를 다음 결과 집합을 검색 하려면이 멤버 함수를 호출 합니다. 현재 결과 집합에서 커서를 완전히 완료 한 경우에 FlushResultSet 를 호출 해야 합니다. Note는 다음 결과 FlushResultSet를 호출 하 여 집합을 검색할 때 커서에서 유효 하지 않습니다 해당 결과 집합이; FlushResultSet 를 호출한 다음 MoveNext 멤버 함수를 호출 해야。

미리 정의 된 쿼리 출력 매개 변수 또는 입력/출력 매개 변수를 사용 하는 경우 이러한 매개 변수 값을 수집 하려면 FALSE (값 0) 반환 될 때까지 FlushResultSet 를 호출 해야 합니다.

ODBC API 함수 SQLMoreResults를 호출 하는 FlushResultSet . SQLMoreResults SQL_ERROR 또는 SQL_INVALID_HANDLE를 반환 하면 FlushResultSet 예외가 throw 됩니다. SQLMoreResults에 대 한 자세한 내용은 ODBC SDK Programmer's Reference 를 참조 하십시오.

예제

다음 코드는 가정 COutParamRecordset 은 CRecordset-파생된 개체를 입력된 매개 변수 및 출력 매개 변수를 미리 정의 된 쿼리를 기반으로 여러 개의 결과 집합이 필요 합니다. 참고 구조 DoFieldExchange 의 재정의。

// DoFieldExchange override
//
// Only necessary to handle parameter bindings.
// Don't use CRecordset-derived class with bound
// fields unless all result sets have same schema
// OR there is conditional binding code.

void COutParamRecordset::DoFieldExchange( CFieldExchange* pFX )
{
   pFX->SetFieldType( CFieldExchange::outputParam );
   RFX_Long( pFX, "Param1", m_nOutParamInstructorCount );
         // The "Param1" name here is a dummy name 
         // that is never used

   pFX->SetFieldType( CFieldExchange::inputParam );
   RFX_Text( pFX, "Param2", m_strInParamName );
         // The "Param2" name here is a dummy name 
         // that is never used

}


// Now implement COurParamRecordset.

// Assume db is an already open CDatabase object
COutParamRecordset rs( &db );
rs.m_strInParamName = _T("Some_Input_Param_Value");

// Get the first result set
// NOTE: SQL Server requires forwardOnly cursor 
//       type for multiple rowset returning stored 
//       procedures
rs.Open( CRecordset::forwardOnly, 
         "{? = CALL GetCourses( ? )}", 
         CRecordset::readOnly);

// Loop through all the data in the first result set
while ( !rs.IsEOF( ) )
{
   CString strFieldValue;
   for( int nIndex = 0; 
        nIndex < rs.GetODBCFieldCount( ); 
        nIndex++ )
   {
      rs.GetFieldValue( nIndex, strFieldValue );

      // TO DO: Use field value string.
   }
   rs.MoveNext( );
}

// Retrieve other result sets...
while( rs.FlushResultSet( ) )
{
   // must call MoveNext because cursor is invalid
   rs.MoveNext( );

   while ( !rs.IsEOF( ) )
   {
      CString strFieldValue;
      for( int nIndex = 0; 
           nIndex < rs.GetODBCFieldCount( ); 
           nIndex++ )
      {
         rs.GetFieldValue( nIndex, strFieldValue );

         // TO DO: Use field value string.
      }
      rs.MoveNext( );
   }
}


// All result sets have been flushed. Cannot
// use the cursor, but the output parameter,
// m_nOutParamInstructorCount, has now been written.
// Note that m_nOutParamInstructorCount not valid until
// CRecordset::FlushResultSet has returned FALSE,
// indicating no more result sets will be returned.

// TO DO: Use m_nOutParamInstructorCount

// Cleanup
rs.Close( );
db.Close( );

CRecordset 개요 |nbsp; 클래스 멤버 (ko) | 계층 구조 차트(&N)

참고 항목nbsp;CFieldExchange::SetFieldType(&N)

Index