title: ORA-22275: invalid LOB locator specified
body: <p>I have huge Oracle function which is used to calculate data from 6 tables.</p>
  
  <pre><code>create or replace FUNCTION STATISTICS_FUNCTION(NAMEIN IN VARCHAR2
  
  )
  RETURN CLOB
  AS
      LAST_60_CPU NUMBER;
      .............
  
      LINE CLOB;
  
      CURSOR LAST_60_CPU_CURSOR IS
       .................
  
  BEGIN
  
      LINE := EMPTY_CLOB();
      DBMS_LOB.CREATETEMPORARY(LINE,true);
    OPEN LAST_60_CPU_CURSOR;
     LOOP
        FETCH LAST_60_CPU_CURSOR INTO LAST_60_EVENT_DATE, LAST_60_CPU;
        ....................
        DBMS_LOB.APPEND(LINE, TO_CHAR(LAST_60_EVENT_DATE));
        DBMS_LOB.APPEND(LINE, 'I');
        DBMS_LOB.APPEND(LINE, TO_CHAR(LAST_60_CPU));
        DBMS_LOB.APPEND(LINE, CHR(10));
     END LOOP;
     CLOSE LAST_60_CPU_CURSOR;
     DBMS_LOB.APPEND(LINE, 'LAST_60_CPU');
     DBMS_LOB.APPEND(LINE, CHR(10));
  .......................................................
  
  -------------------------------------
  DBMS_OUTPUT.PUT_LINE(LINE);
  
    RETURN LINE;
  END STATISTICS_FUNCTION;
  </code></pre>
  
  <p>I use this Java code to call the function:</p>
  
  <pre><code>public void callFunction() throws SQLException
  {
  // initialize the driver and try to make a connection
  
  DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "admin", "qwerty");
  
  // prepareCall uses ANSI92 "call" syntax
  CallableStatement cstmt = conn.prepareCall("{? = call AGENT_STATISTICS_FUNCTION(?)}");
  
  // get those bind variables and parameters set up
  cstmt.registerOutParameter(1, Types.VARCHAR);
  cstmt.setString(2, "agent");
  
  // now we can do it, get it, close it, and print it
  cstmt.execute();
  String result = cstmt.getString(1);
  conn.close();
  System.out.println(result);
  }
  </code></pre>
  
  <p>I tired to call the function without this line:</p>
  
  <pre><code>DBMS_LOB.CREATETEMPORARY(LINE,true);
  </code></pre>
  
  <p>But I get error:</p>
  
  <pre><code>Connecting to the database local.
  ORA-22275: invalid LOB locator specified
  ORA-06512: at "SYS.DBMS_LOB", line 639
  ORA-06512: at "ADMIN.STATISTICS_FUNCTION", line 596
  ORA-06512: at line 7
  Process exited.
  Disconnecting from the database local.
  </code></pre>
  
  <p>Do you have any idea why I get this error without DBMS_LOB.CREATETEMPORARY(LINE,true);?</p>