OCIを使用してC++アプリケーションを開発しています。DBからOCINumberにデータをフェッチする必要があります。OCINumbersで関数OCIDefineByPos()を使用する方法について混乱しています。誰かがこれで私を助けることができますか?
以下に示すのは、OCIDefineByPos関数を呼び出すコードの一部です。pStmtはOCIStmt*であり、p_ErrorはOCIError*です。以下の関数ポインタが使用されます。
1. pf_OCINumberFromReal = function pointer to OCINumberFromReal
2. pf_OCINumberToReal = function pointer to OCINumberToReal
3. pf_DefineByPos = function pointer to OCIDefineByPos.
OCINumber ocinTest;
long double dnum = 0.0;
(*pf_OCINumberFromReal)(p_Error, &dnum, sizeof(dnum), &ocinTest);
int iLength1 = sizeof(ocinTest);
OCIDefine* pDfn = NULL;
iRet = (*pf_DefineByPos)(pStmt, &pDfn, p_Error, 1, (dvoid *) &ocinTest,
(sword) iLength1, SQLT_NUM, (dvoid *) 0, (ub2 *)0,
(ub2 *)0, OCI_DEFAULT);
if (iRet == OCI_SUCCESS)
{
(*pf_OCINumberToReal)(p_Error, &ocinTest, sizeof(dnum), &dnum);
std::cout <<std::fixed << std::setprecision (10) << dnum << std::endl;
}
iRet = OCI_SUCCESSですが、データベース内の値を正しくフェッチしませんでした(pStmtを使用して定義されたSQLクエリの値)。呼び出し後もdnumは0.0です。このpf_DefineByPosは、int、doubleなどの他のデータ型で正常に機能しています。
だから誰かが私がこれに関する問題を見つけるのを手伝ってくれる?