Problem with PLSQL function returning CLOB

Ivan3138

Member
Hello,

I have used Package wizard to make a wrapper around my package. It created this function:

// SHP_DOC_GEN.GET_DOCUMENT
function TShpDocGen.GetDocument(Document: Double): TLOBLocator;
begin
Result := TLOBLocator.Create(Session, otCLOB);
try
GetQuery;
OCPQuery.DeclareVariable('function_result', otCLOB);
OCPQuery.SetComplexVariable('function_result', Result);
OCPQuery.DeclareVariable('DOCUMENT', otFloat);
OCPQuery.SetVariable('DOCUMENT', Document);
OCPQuery.SQL.Add('begin');
OCPQuery.SQL.Add(' :function_result := "SHP_DOC_GEN"."GET_DOCUMENT"(DOCUMENT =>
biggrin.gif
OCUMENT);');
OCPQuery.SQL.Add('end;');
OCPQuery.Execute;
except
Result.Free;
raise;
end;
end;

When I call it from my code like this:

memo2.Lines.LoadFromStream(pckg.GetDocument(doc_id));

I am getting access violation at this line in
function wrapper:

GetQuery;

What am I doing wrong? I couldn't find any help what GetQuery is doing...

Where is GetQuery and OCPQuery declared?

Thanks,
Ivan
 
OCPQuery is a protected TOracleQuery variable of the TOracleCustomPackage base class, from which your TShpDocGen class is derived. The GetQuery procedure initializes the OCPQuery. I can't imagine why this would cause an access violation, unless your pckg variable (or the session to which it linked) is not yet instantiated or already freed.

------------------
Marco Kalter
Allround Automations
 
Back
Top