在.net下用c++写的代码如下:
// testClob.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "oracl.h"
#include <iostream>
#include <fstream>using namespace std;// Example for OClob::Read
int main()
{     //Initialize oo4o, connect, execute sql
    OStartup();
    ODatabase odb("hjx", "sys", "yellow");    //ODynaset odyn(odb, "SELECT * FROM test"); ODynaset odyn(odb, "SELECTCOLB * FROM test");
    if (!odyn.IsOpen())
    {    
        cout <<"Connect Error: "<<odb.GetErrorText()<<endl;

        cout <<"SQL Error: "<<odyn.GetErrorText()<<endl;
        return 1;
    }
   
    OClob oclob;
    
     int a;

     odyn.GetFieldValue("count",&a);  

cout<<a;

    unsigned char *buffer = 0;
if(!oclob.IsNull())
{
cout<<"Clob is not null."<<endl;
} else{       //under the condition that the oclob is null!!!
cout<<"Clob is null."<<endl; const char buf2[] = "Clob is null.";
ofs.write(buf2, sizeof(buf2)); if(oclob.IsOpen())
cout<<"Clob is open.."<<endl;
    try   //test result that is the oclob is null, any opration is permitted!!!
    {
        fstream fs;
fs.open("c:\\descout.txt", ios::out);

        unsigned long size = oclob.GetSize();                   
        // calculate an optimum buffersize of approximately 32k bytes
        
unsigned long optchunk = oclob.GetOptimumChunkSize();        

        unsigned int bufsize = ((int)(32768/optchunk)) *optchunk;
        if (bufsize > size)
            bufsize = size;        buffer = (unsigned char *)malloc(bufsize);        //By taking advantage of streaming we get the best performance
        //and do not need to allocate a large buffer
        

        short status= OLOB_NEED_DATA;
        unsigned long amtread=0;
        
cout<<"22";        while(status == OLOB_NEED_DATA)
        {            amtread = oclob.Read(&status, buffer, bufsize);       //added to convert the type char *tebuffer;
tebuffer = (char*)buffer;

cout <<buffer<<endl;
            
fs.write(tebuffer, amtread);
        }
        
        oclob.DisableStreaming();    
        fs.close();
    }
    catch(OException E)   //there is an exception which throw to the dos platform:  clob.getsize() Error:opreation was not permitted on a null lob 
{
        cout<<"11"<<E.GetFailedMethodName()<< " Error: "<<E.GetErrorText()<<endl;
const char buf3[] = "some failure!";
ofs.write(buf3, sizeof(buf3));
    }//catch
   }//else
    if (buffer)
        free(buffer); getchar();
    
    OShutdown();
    return 0;
}