HELP! Oracle error with ORA-01019
Hi guys,
Code:
CString GetQueryValue(CString strConnectionString, CString strQuery)
{
CString strResult;
CoInitialize(NULL);
try
{
_ConnectionPtr cn("ADODB.Connection");
_RecordsetPtr rs("ADODB.Recordset");
_bstr_t strMissing(L"");
cn->Open(strConnectionString.AllocSysString(), strMissing, "", adConnectUnspecified);
rs->Open(strQuery.AllocSysString(), _variant_t((IDispatch *) cn, true), adOpenKeyset, adLockOptimistic, adCmdText);
if (!rs->EndOfFile)
{
_variant_t vtValue;
vtValue.vt = VT_NULL||VT_BSTR||VT_EMPTY;
vtValue = rs->Fields->Item[(long) 0]->Value;
if (vtValue.vt == VT_NULL)
{
strResult = L"";
}
else
{
strResult.Format(L"%s", (WCHAR*) ((_bstr_t) vtValue));
}
}
else
{
strResult = L"";
}
rs->Close();
cn->Close();
rs = NULL;
cn = NULL;
return strResult;
}
catch (_com_error &e)
{
CString szError;
szError.Format(L"Recordset error: %s", (WCHAR*) e.Description());
DumpLog(szError);
szError.Format(L"Query was: %s", strQuery);
DumpLog(szError);
return L"";
}
::CoUninitialize();
}
I use the above codes to send queries to an oracle database. But I received an exception "Recordset error: Error while trying to retrieve text for error ORA-01019".
Can anyone shed some lights on what could be the problem and how to resolve?
Re: HELP! Oracle error with ORA-01019
Hi all.
I found this explanation about the error you got.
ORA-01019 unable to allocate memory in the user side
Cause: The user side memory allocator returned an error.
Action: Increase the size of the process heap or switch to the old set of calls.
Hard to say what is happening, and how to solve. Surely the problem don't depend on the queries, but probably the C++ code is wrong.
I hope this will help you.
Re: HELP! Oracle error with ORA-01019
Hi Davide++,
Thanks for your reply.
I know about the explanations that you posted, which is the standard answer from oracle documentation and i don't think is applicable in this case.
The same c++ code is deployed on another project involving oracle database and it works well. I was more inclined into thinking that the problem lies with the oracle client's configuration of my current project, but I wasn't the person who setup the oracle installation.
Hope anyone familiar with oracle installation / configuration can help to solve this issues. Btw, this machine is using oracle instant client.
Re: HELP! Oracle error with ORA-01019
The problem might be caused by AllocSysString()
According to MSDN, http://msdn.microsoft.com/en-us/libr...s1(VS.71).aspx
Quote:
"Commonly, if this string is passed to a COM function (as an [in] parameter) this requires the caller to free the string. This can be done by using SysFreeString, as described in the Platform SDK. See Strings: Allocating and Releasing Memory for a BSTR for more information on determining when the string is freed by the caller."
Re: HELP! Oracle error with ORA-01019
Quote:
Originally Posted by
olivthill2
Thanks for the suggestions. I have tried using SysFreeString to release the memory allocated but the problem still occurs.
In fact, though the lack of memory deallocation will cause memory leaks, I don't think it will throw any exception. After some debugging, I have narrowed down the line that throw the exception:
Code:
cn->Open(bstrConnString, strMissing, "", adConnectUnspecified);
Note: I have modified the code a bit to facilitate memory deallocation as suggested, so the first parameter bstrConnString is actually the BSTR returned by AllocSysString().
I kinda suspect it is due to the oracle client's configuration. So if anyone has encountered this error ORA-01019 before, please kindly share with me your experiences.
Re: HELP! Oracle error with ORA-01019
Any one has any idea why this following line generate an exception (ORA-01019):
Code:
cn->Open(bstrConnString, "", "", adConnectUnspecified);
Full source code above in the first post. Any suggestion are welcome. What would be the possible configuration that need to be set if this is an oracle client's config problem?