OCIErrorGet raise Access violation when Error = 12543

Devil

Member²
In my appliction when database alias is wrong i need catch this error
(for example in tnsnames.ora I create some alias testdb of database for
tnsping testdb return TNS-12543 TNS:destination host unreachable)

I do this code in my program:
try
//ReturnCode := FSourceOracleQuery.Session.ReturnCode; //It's OK!!!
if not FSourceOracleQuery.Session.Connected
and
(FSourceOracleQuery.Session.CheckConnection(True) = ccError)
then raise EOracleError.Create(FSourceOracleQuery.Session,
FSourceOracleQuery.Session.ReturnCode,
FSourceOracleQuery);

except
on E: EOracleError do
begin
if E.ErrorCode = 12543
then begin
WriteToLog(E.Message, mtError);
raise;
end;
end;
end;

But, in EOracleError.Create constructor on line:
{Error = 12543}
OCIErrorGet(OCIError(Error), 1, nil, ub4(Error), Msg, SizeOf(Msg), OCI_HTYPE_ERROR);
raised Access violation at address 60601FC5 in module 'OraClient9.Dll'. Read of address 000030FF

and except ... end block not executed.

Why raise Access Violation?
Perhaps TNS-12543 is TNS error and not OCI and in OraClient9.Dll not entry for error OCIError(Error), where Error = 12543.

Who help me please?

Or who tell me another way for raise EOracleError.Create?
 
I partially solve this problem, but actually i think that is not perfect solution
and the best there is raise EOracleError.

My solve this problem:
if not FSourceOracleQuery.Session.Connected
and
(FSourceOracleQuery.Session.CheckConnection(True) = ccError)
then begin
ReturnCode := FSourceOracleQuery.Session.ReturnCode;
if ReturnCode = 12543
then begin
raise Exception.CreateFmt('TNS:destination host unreachable for database alias: %s', [FSourceOracleQuery.Session.LogonDatabase]);
end
else begin
raise EOracleError.Create(FSourceOracleQuery.Session,
FSourceOracleQuery.Session.ReturnCode,
FSourceOracleQuery);
end;
end;

Please write your solve for this problem or what your think?
 
Or how get ErrorMessage for my nlslanguage from Oracle Error Server Messages for Error code 12543 not using function: OCIErrorGet(OCIError(Error), 1, nil, ub4(Error), Msg, SizeOf(Msg), OCI_HTYPE_ERROR);
 
For ErrorMessage by ErrorCode I find solve:
raise Exception.Create(FSourceOracleQuery.Session.ErrorMessage(ReturnCode));

Another question is relevant(important)
 
This error:
raised Access violation at address 60601FC5 in module 'OraClient9.Dll'. Read of address 000030FF
indicates an Oracle Client bug. There is not much one can do with such an Access Violation.
 
And what i do?
I was use:
raise Exception.Create(FSourceOracleQuery.Session.ErrorMessage(ReturnCode));

instead of:
raise EOracleError.Create(FSourceOracleQuery.Session, FSourceOracleQuery.Session.ReturnCode, FSourceOracleQuery);
???

For example in pl/sql developer on Oracle logon database form for TNS-12543 TNS:destination host unreachable not generated Access Violation and shown message with text of error.
How we do this or processed it?
 
Back
Top