1
我在INT8類型的IBM Informix數據庫中有一個字段可容納20位數字。什麼應該是MSVC++(RFX等效數據類型)中的等效數據類型?我使用的是Visual C++,而我的IDE是Visual Studio 6.0。IBM Informix數據庫中INT8類型的RFX等效數據類型
領域initial_amount會聲明如下:
RFX_Int64(pFX, _T("[initial_amount]"), m_initial_amount);
我已經寫了相同下面的自定義RFX定義代碼。 但似乎有問題。
void AFXAPI RFX_Int64(CFieldExchange* pFX, LPCTSTR szName, __int64& value)
{
ASSERT(AfxIsValidAddress(pFX, sizeof(CFieldExchange)));
ASSERT(AfxIsValidString(szName));
UINT nField;
if (!pFX->IsFieldType(&nField))
return;
LONG* plLength = pFX->m_prs->GetFieldLengthBuffer(nField - 1, pFX->m_nFieldType);
switch (pFX->m_nOperation)
{
case CFieldExchange::BindFieldToColumn:
{
#ifdef _DEBUG
// Assumes all bound fields BEFORE unbound fields
CODBCFieldInfo* pODBCInfo =
&pFX->m_prs->m_rgODBCFieldInfos[nField - 1];
if (pODBCInfo->m_nSQLType != SQL_C_DOUBLE &&
pODBCInfo->m_nSQLType != SQL_FLOAT)
{
// Warn of possible field schema mismatch
if (afxTraceFlags & traceDatabase)
TRACE1("Warning: double converted from SQL type %ld.\n",
pODBCInfo->m_nSQLType);
}
#endif
}
// fall through
default:
LDefault:
pFX->Default(szName, &value, plLength, SQL_BIGINT ,
sizeof(value), 22);
return;
case CFieldExchange::Fixup:
if (*plLength == SQL_NULL_DATA)
{
pFX->m_prs->SetNullFieldStatus(nField - 1);
value = afxDoublePseudoNull;
}
return;
case CFieldExchange::SetFieldNull:
if ((pFX->m_pvField == NULL &&
pFX->m_nFieldType == CFieldExchange::outputColumn) ||
pFX->m_pvField == &value)
{
if (pFX->m_bField)
{
pFX->m_prs->SetNullFieldStatus(nField - 1);
value = afxDoublePseudoNull;
*plLength = SQL_NULL_DATA;
}
else
{
pFX->m_prs->ClearNullFieldStatus(nField - 1);
*plLength = sizeof(value);
}
#ifdef _DEBUG
pFX->m_nFieldFound = nField;
#endif
}
return;
case CFieldExchange::MarkForAddNew:
// can force writing of psuedo-null value (as a non-null) by setting field dirty
if (value != afxDoublePseudoNull)
{
pFX->m_prs->SetDirtyFieldStatus(nField - 1);
pFX->m_prs->ClearNullFieldStatus(nField - 1);
}
return;
case CFieldExchange::MarkForUpdate:
if (value != afxDoublePseudoNull)
pFX->m_prs->ClearNullFieldStatus(nField - 1);
goto LDefault;
case CFieldExchange::AllocCache:
{
CFieldInfo* pInfo = &pFX->m_prs->m_rgFieldInfos[nField - 1];
pInfo->m_pvDataCache = new __int64;
pInfo->m_nDataType = AFX_RFX_DOUBLE;
}
return;
#ifdef _DEBUG
// case CFieldExchange::DumpField:
// {
// *pFX->m_pdcDump << "\n" << szName << " = " << value;
// }
return;
#endif //_DEBUG
}
}
此代碼是否適用於Visual C++ 6.0?如果不是,那我該怎麼辦?