1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

One question when insert large LOB with OCCI

Discussion in 'Oracle Development General' started by Totulas, Oct 9, 2013.

  1. Totulas

    Totulas Active Member

    Likes Received:
    Trophy Points:
    Hello, everyone! I have encountered a problem when insert large LOB with OCCI. Hope I can get some solutions here.

    const int SIZE_MAX = 100000;
    const int BUFFER_SIZE = 1000;
    Statement *stmt = conn->createStatement(
    "Insert Into testtab(longcol) values :)1)");
    stmt->setCharacterStreamMode(1, SIZE_MAX );

    Stream *instream = stmt->getStream(1);
    char buffer[BUFFER_SIZE];
    ...// Fill buffer with data.
    instream->writeBuffer(buffer, dataLen);
    ...// Fill buffer with data.
    instream->writeLastBuffer(buffer, dataLen);

    My Question:
    The second parameter of setCharacterStreamMode (refer it as SIZE) seems to be the maximum data size to be inserted. That is to say, this value must be no less than the size of data to be inserted. But because in function setCharacterStreamMode, memory with size SIZE will be allocated, this incurs a problem: If the LOB data to be inserted is very large, such as 4G bytes, then SIZE must be at least 4G. But a request of 4G memory is impossible.

    Dose there exist some ways to handle this problem. I need to insert large LOB data but I cannot affort the memory cost. By the way, I know another wayto insert LOB data, that is insert an empty LOB locator first and then find the record using "select" clause, then put the real LOB data. But this is not what I want since the "select" operation is not that convenient in my application.

    Thanks !