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)