Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8675953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:04:27+00:00 2026-06-12T20:04:27+00:00

From a store procedure I want to output a CLOB , because a varchar2

  • 0

From a store procedure I want to output a CLOB, because a varchar2 is not long enough (even if I just use 255 chars in this example).

I found some oracle examples and tried to use them with my code. But sadly there seems no content to be inside of my CLOB. How can I write properly into the CLOB?

Here is what the C++ code looks like:

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;
    versioninfo = "103";

    oraub8 written = 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*/NULL, /*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;
    return;
}

The SP is registered 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);

I call the SP like this:

declare
  res clob;
  begin
  --dbms_lob.createtemporary(res,true);
  version(res);
  dbms_output.put_line(dbms_lob.substr(res, 255, 0));
end;

As you can see I also tried allocating the CLOB before calling the SP, but that didn’t help much. What did I miss?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:04:28+00:00Added an answer on June 12, 2026 at 8:04 pm

    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;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a somewhat-long-running stored procedure being called from a PB application. I want
I want to be able to get some output from mysql stored procedure within
I want to use some smart procedures I wrote, but not store them. For
I want to fill jqGrid from a stored procedure, there was 1 good example
I want to call stored procedure from a trigger, how to execute that stored
I have a stored procedure that I want to call from within another, and
I am going to be executing an Update stored procedure from .NET. I want
I want to (loosely) have a stored procedure like select * from table where
In asp.net(C#) i want to fetch data from a database using a stored procedure
I have a stored procedure. I want to call a function from it. Want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.