Home » Developer & Programmer » Precompilers, OCI & OCCI » Keep getting ORA-22275 from extproc (ORACLE-XE 11g)
Keep getting ORA-22275 from extproc [message #567290] |
Wed, 26 September 2012 04:30 |
|
MistaPink
Messages: 2 Registered: September 2012
|
Junior Member |
|
|
Hi,
I am trying to give back data from a stored procedure written in C. I registered the functions as follows:
create or replace
procedure version(versioninfo OUT clob) as
external name "version" library myLib language c with context
parameters (context, versioninfo, versioninfo INDICATOR SB4);
It compiles fine. The function being called look like this:
extern "C" DLLEXPORT
void version(OCIExtProcContext* context, OCILobLocator **out, sb4 *ind_out){
OCIEnv* envh;
OCISvcCtx* svch;
OCIError* errh;
OCIExtProcGetEnv (context, &envh, &svch, &errh);
std::string versioninfo = "104";
oraub8 maxChar = 10;
OCIDescriptorAlloc(envh,
(dvoid **) out,
(ub4) OCI_DTYPE_LOB, /* Type of Descriptor */
(size_t) 0,
(dvoid **) 0);
OCILobTrim2(svch,
errh,
*out,
(ub4)1);
OCILobWrite2(/*svcctx*/svch, /*errh*/errh, /*ociloblocator*/*out,
/*byte_amtp*/NULL, /*char_amtp*/&maxChar, /*offset*/1,
/*bufp*/(void*)versioninfo.c_str(), /*buflen*/versioninfo.size(),
/*piece*/OCI_ONE_PIECE, /*context for callback*/NULL,
/*callback*/NULL, /*csid*/0, /*csfrm*/SQLCS_IMPLICIT);
*ind_out = 0;
}
If I execute the procedure with SQLDeveloper by pressing "play" it is getting executed but there is no result. If I try to execute it from an anonymous block it results in ORA-22275 instead of doing anything.
declare
res clob;
begin
-- the following doesnt help much
--dbms_lob.createtemporary(res,true);
version(res);
dbms_output.put_line(res);
end;
Actually I have to questions:
1.) Why does Oracle give me the error? In my opinion all requirements mentioned by the error description are met.
2.) Why is there no output when executing the function via SQL Developer? Is the usage of OCILobWrite wrong?
Thank you all in advance and I am looking forward to you answers and suggestions.
|
|
|
Re: Keep getting ORA-22275 from extproc [message #568437 is a reply to message #567290] |
Thu, 11 October 2012 09:56 |
|
MistaPink
Messages: 2 Registered: September 2012
|
Junior Member |
|
|
Solved it by using `OCILobCreateTemporary` before working with that CLOB.
OCIDescriptorAlloc(envh,
(dvoid **) out,
(ub4) OCI_DTYPE_LOB, /* Type of Descriptor */
(size_t) 0,
(dvoid **) 0);
OCILobCreateTemporary(svch, errh, *out, 0, SQLCS_IMPLICIT, OCI_TEMP_CLOB, OCI_ATTR_NOCACHE, OCI_DURATION_CALL);
ub4 amt = static_cast<ub4>(result.size());
OCILobTrim2(svch,
errh,
*out,
(ub4)amt);
oraub8 amtp = static_cast<oraub8>(result.size());
OCILobWrite2(/*svcctx*/svch, /*errh*/errh, /*ociloblocator*/*out,
/*byte_amtp*/NULL, /*char_amtp*/&amtp, /*offset*/1,
/*bufp*/reinterpret_cast<dvoid*>(const_cast<char*>(result.c_str())), /*buflen*/amt,
/*piece*/OCI_ONE_PIECE, /*context for callback*/NULL,
/*callback*/NULL, /*csid*/0, /*csfrm*/SQLCS_IMPLICIT);
*ind = 0;
|
|
|
|
Goto Forum:
Current Time: Wed Jan 22 23:11:52 CST 2025
|