global temporary table --> invalid ROWID?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Corrine

    global temporary table --> invalid ROWID?

    Hi,

    I am creating a global temporary table that is session-specific. I
    insert a BLOB into this table, and then select the BLOB from this
    table into a ResultSet. The ResultSet sees this BLOB object, and I am
    able to get the binary input stream from this blob. However, when I
    invoke InputStream.rea d(byte[]) on this input stream, I get the
    following exception:

    java.io.IOExcep tion: ORA-01410: invalid ROWID
    ORA-06512: at "SYS.DBMS_L OB", line 751
    ORA-06512: at line 1


    at oracle.jdbc.dba ccess.DBError.S QLToIOException (DBError.java:6 25)

    at oracle.jdbc.dri ver.OracleBlobI nputStream.need Bytes(OracleBlo bInputStream.ja va:179)

    at oracle.jdbc.dri ver.OracleBuffe redStream.read( OracleBufferedS tream.java:113)

    at oracle.jdbc.dri ver.OracleBuffe redStream.read( OracleBufferedS tream.java:91)
    ...

    Just for clarity, here is basically the code I'm using:

    CallableStateme nt cstmt2 = db.prepareCall( "commit");
    CallableStateme nt cstmt = db.prepareCall( "create global temporary
    table temp_table (blobid NUMBER unique, blob_col BLOB) on commit
    preserve rows");
    cstmt.execute() ;
    cstmt.close();
    cstmt2.execute( );
    CallableStateme nt cstmt1 = db.prepareCall( "insert into temp_table
    values (1, empty_blob())") ;
    cstmt1.execute( );
    cstmt1.close();
    cstmt2.execute( );
    cstmt2.close();

    CallableStateme nt plsqlblock =
    db.prepareCall( stringThatFills InEmptyBlobInTe mpTable);
    plsqlblock.exec ute();
    plsqlblock.clos e();

    PreparedStateme nt pstmt1 = db.prepareState ment("select blob_col from
    temp_table where blobid = 1");
    ResultSet rset = pstmt1.executeQ uery();
    BLOB bl;
    if (rset.next())
    {
    System.out.prin tln("success.") ; //<--- This prints out.
    bl = ((OracleResultS et)rset).getBLO B(1);
    }
    pstmt1.close();

    InputStream bis = bl.getBinaryStr eam();
    int numBytes = 0;
    byte[] theBytes = new byte[appropriateLeng th];
    numBytes = bis.read(theByt es); ///*******EXCEPTIO N HAPPENS
    HERE!!!!


    I would also like to mention that when I change temp_table to be just
    a regular table, everything works correctly.

    What's the problem, and how do I fix it?

    Thanks,

    Corrine
  • Oracle_Technet

    #2
    Re: global temporary table --&gt; invalid ROWID?

    Reason as per my understanding: java front end would be using
    connection pooling, and the session is not bound. so once the back end
    proc gives the output back to front end, and then the front end tries
    to access the blob stored in the global temp table, it will give
    error, as global temp table is session specific. (so rowid not found).
    Same type of errors would be encountered with ref cursors based on
    global temp tables.
    So, don't use Global Temporary tables for returning resultsets to java
    front end.
    Hope this helps.

    JavaDeveloper@v olcanomail.com (Corrine) wrote in message news:<54774824. 0309290654.58fb 3f16@posting.go ogle.com>...
    Hi,
    >
    I am creating a global temporary table that is session-specific. I
    insert a BLOB into this table, and then select the BLOB from this
    table into a ResultSet. The ResultSet sees this BLOB object, and I am
    able to get the binary input stream from this blob. However, when I
    invoke InputStream.rea d(byte[]) on this input stream, I get the
    following exception:
    >
    java.io.IOExcep tion: ORA-01410: invalid ROWID
    ORA-06512: at "SYS.DBMS_L OB", line 751
    ORA-06512: at line 1
    >
    >
    at oracle.jdbc.dba ccess.DBError.S QLToIOException (DBError.java:6 25)
    >
    at oracle.jdbc.dri ver.OracleBlobI nputStream.need Bytes(OracleBlo bInputStream.ja va:179)
    >
    at oracle.jdbc.dri ver.OracleBuffe redStream.read( OracleBufferedS tream.java:113)
    >
    at oracle.jdbc.dri ver.OracleBuffe redStream.read( OracleBufferedS tream.java:91)
    ...
    >
    Just for clarity, here is basically the code I'm using:
    >
    CallableStateme nt cstmt2 = db.prepareCall( "commit");
    CallableStateme nt cstmt = db.prepareCall( "create global temporary
    table temp_table (blobid NUMBER unique, blob_col BLOB) on commit
    preserve rows");
    cstmt.execute() ;
    cstmt.close();
    cstmt2.execute( );
    CallableStateme nt cstmt1 = db.prepareCall( "insert into temp_table
    values (1, empty_blob())") ;
    cstmt1.execute( );
    cstmt1.close();
    cstmt2.execute( );
    cstmt2.close();
    >
    CallableStateme nt plsqlblock =
    db.prepareCall( stringThatFills InEmptyBlobInTe mpTable);
    plsqlblock.exec ute();
    plsqlblock.clos e();
    >
    PreparedStateme nt pstmt1 = db.prepareState ment("select blob_col from
    temp_table where blobid = 1");
    ResultSet rset = pstmt1.executeQ uery();
    BLOB bl;
    if (rset.next())
    {
    System.out.prin tln("success.") ; //<--- This prints out.
    bl = ((OracleResultS et)rset).getBLO B(1);
    }
    pstmt1.close();
    >
    InputStream bis = bl.getBinaryStr eam();
    int numBytes = 0;
    byte[] theBytes = new byte[appropriateLeng th];
    numBytes = bis.read(theByt es); ///*******EXCEPTIO N HAPPENS
    HERE!!!!
    >
    >
    I would also like to mention that when I change temp_table to be just
    a regular table, everything works correctly.
    >
    What's the problem, and how do I fix it?
    >
    Thanks,
    >
    Corrine

    Comment

    • Jim Kennedy

      #3
      Re: global temporary table --&gt; invalid ROWID?

      "Oracle_Technet " <oracle_technet @yahoo.comwrote in message
      news:c3e04899.0 310022230.799c3 a82@posting.goo gle.com...
      Reason as per my understanding: java front end would be using
      connection pooling, and the session is not bound. so once the back end
      proc gives the output back to front end, and then the front end tries
      to access the blob stored in the global temp table, it will give
      error, as global temp table is session specific. (so rowid not found).
      Same type of errors would be encountered with ref cursors based on
      global temp tables.
      So, don't use Global Temporary tables for returning resultsets to java
      front end.
      Hope this helps.
      >
      JavaDeveloper@v olcanomail.com (Corrine) wrote in message
      news:<54774824. 0309290654.58fb 3f16@posting.go ogle.com>...
      Hi,

      I am creating a global temporary table that is session-specific. I
      insert a BLOB into this table, and then select the BLOB from this
      table into a ResultSet. The ResultSet sees this BLOB object, and I am
      able to get the binary input stream from this blob. However, when I
      invoke InputStream.rea d(byte[]) on this input stream, I get the
      following exception:

      java.io.IOExcep tion: ORA-01410: invalid ROWID
      ORA-06512: at "SYS.DBMS_L OB", line 751
      ORA-06512: at line 1


      at oracle.jdbc.dba ccess.DBError.S QLToIOException (DBError.java:6 25)

      at
      oracle.jdbc.dri ver.OracleBlobI nputStream.need Bytes(OracleBlo bInputStream.ja v
      a:179)

      at
      oracle.jdbc.dri ver.OracleBuffe redStream.read( OracleBufferedS tream.java:113)

      at
      oracle.jdbc.dri ver.OracleBuffe redStream.read( OracleBufferedS tream.java:91)
      ...

      Just for clarity, here is basically the code I'm using:

      CallableStateme nt cstmt2 = db.prepareCall( "commit");
      CallableStateme nt cstmt = db.prepareCall( "create global temporary
      table temp_table (blobid NUMBER unique, blob_col BLOB) on commit
      preserve rows");
      cstmt.execute() ;
      cstmt.close();
      cstmt2.execute( );
      CallableStateme nt cstmt1 = db.prepareCall( "insert into temp_table
      values (1, empty_blob())") ;
      cstmt1.execute( );
      cstmt1.close();
      cstmt2.execute( );
      cstmt2.close();

      CallableStateme nt plsqlblock =
      db.prepareCall( stringThatFills InEmptyBlobInTe mpTable);
      plsqlblock.exec ute();
      plsqlblock.clos e();

      PreparedStateme nt pstmt1 = db.prepareState ment("select blob_col from
      temp_table where blobid = 1");
      ResultSet rset = pstmt1.executeQ uery();
      BLOB bl;
      if (rset.next())
      {
      System.out.prin tln("success.") ; //<--- This prints out.
      bl = ((OracleResultS et)rset).getBLO B(1);
      }
      pstmt1.close();

      InputStream bis = bl.getBinaryStr eam();
      int numBytes = 0;
      byte[] theBytes = new byte[appropriateLeng th];
      numBytes = bis.read(theByt es); ///*******EXCEPTIO N HAPPENS
      HERE!!!!


      I would also like to mention that when I change temp_table to be just
      a regular table, everything works correctly.

      What's the problem, and how do I fix it?

      Thanks,

      Corrine
      If it works on a regular table then why are you making things more expensive
      by putting it in a temp table first? Just get it out of the regular table.
      Jim


      Comment

      • Corrine

        #4
        Re: global temporary table --&gt; invalid ROWID?

        Is a temporary table really more expensive than a regular table?
        Actually, I prefer a temporary table, because my application serves
        multiple users simultaneously. I am concerned about concurrency
        issues that arise if I use
        just a regular table.

        Speaking of which, what if I use a temporary BLOB rather than a
        temporary table? I am trying to do this now, but I can't figure out
        how to get the modified BLOB object back to Java after the PLSQL block
        has finished executing.

        I do:

        BLOB bl = BLOB.createTemp orary(db,true,B LOB.DURATION_SE SSION);
        CallableStateme nt plsqlblock = conn.prepareCal l(
        "declare\n" +
        " stuff... \n"+
        "begin\n"+
        " procThatModifie sBLOB(?);\n"+
        "end;\n");
        plsqlblock.setB lob(1, bl);
        plsqlblock.exec ute();

        bl = plsqlblock.getB lob(1); //**** doesn't work.

        How do I retrieve the modified value of "bl" after "plsqlblock "
        finishes executing?


        "Jim Kennedy" <kennedy-down_with_spamm ers@no_spam.com cast.netwrote in message news:<Pxffb.485 819$Oz4.329946@ rwcrnsc54>...

        If it works on a regular table then why are you making things more
        expensive
        by putting it in a temp table first? Just get it out of the regular table.
        Jim
        "Oracle_Technet " <oracle_technet @yahoo.comwrote in message
        news:c3e04899.0 310022230.799c3 a82@posting.goo gle.com...
        Reason as per my understanding: java front end would be using
        connection pooling, and the session is not bound. so once the back end
        proc gives the output back to front end, and then the front end tries
        to access the blob stored in the global temp table, it will give
        error, as global temp table is session specific. (so rowid not found).
        Same type of errors would be encountered with ref cursors based on
        global temp tables.
        So, don't use Global Temporary tables for returning resultsets to java
        front end.
        Hope this helps.

        JavaDeveloper@v olcanomail.com (Corrine) wrote in message
        news:<54774824. 0309290654.58fb 3f16@posting.go ogle.com>...
        Hi,
        >
        I am creating a global temporary table that is session-specific. I
        insert a BLOB into this table, and then select the BLOB from this
        table into a ResultSet. The ResultSet sees this BLOB object, and I am
        able to get the binary input stream from this blob. However, when I
        invoke InputStream.rea d(byte[]) on this input stream, I get the
        following exception:
        >
        java.io.IOExcep tion: ORA-01410: invalid ROWID
        ORA-06512: at "SYS.DBMS_L OB", line 751
        ORA-06512: at line 1
        >
        >
        at oracle.jdbc.dba ccess.DBError.S QLToIOException (DBError.java:6 25)
        >
        at
        oracle.jdbc.dri ver.OracleBlobI nputStream.need Bytes(OracleBlo bInputStream.ja v
        a:179)
        >
        at
        oracle.jdbc.dri ver.OracleBuffe redStream.read( OracleBufferedS tream.java:113)
        >
        at
        oracle.jdbc.dri ver.OracleBuffe redStream.read( OracleBufferedS tream.java:91)
        ...
        >
        Just for clarity, here is basically the code I'm using:
        >
        CallableStateme nt cstmt2 = db.prepareCall( "commit");
        CallableStateme nt cstmt = db.prepareCall( "create global temporary
        table temp_table (blobid NUMBER unique, blob_col BLOB) on commit
        preserve rows");
        cstmt.execute() ;
        cstmt.close();
        cstmt2.execute( );
        CallableStateme nt cstmt1 = db.prepareCall( "insert into temp_table
        values (1, empty_blob())") ;
        cstmt1.execute( );
        cstmt1.close();
        cstmt2.execute( );
        cstmt2.close();
        >
        CallableStateme nt plsqlblock =
        db.prepareCall( stringThatFills InEmptyBlobInTe mpTable);
        plsqlblock.exec ute();
        plsqlblock.clos e();
        >
        PreparedStateme nt pstmt1 = db.prepareState ment("select blob_col from
        temp_table where blobid = 1");
        ResultSet rset = pstmt1.executeQ uery();
        BLOB bl;
        if (rset.next())
        {
        System.out.prin tln("success.") ; //<--- This prints out.
        bl = ((OracleResultS et)rset).getBLO B(1);
        }
        pstmt1.close();
        >
        InputStream bis = bl.getBinaryStr eam();
        int numBytes = 0;
        byte[] theBytes = new byte[appropriateLeng th];
        numBytes = bis.read(theByt es); ///*******EXCEPTIO N HAPPENS
        HERE!!!!
        >
        >
        I would also like to mention that when I change temp_table to be just
        a regular table, everything works correctly.
        >
        What's the problem, and how do I fix it?
        >
        Thanks,
        >
        Corrine
        >
        >

        Comment

        • Jim Kennedy

          #5
          Re: global temporary table --&gt; invalid ROWID?

          "Corrine" <JavaDeveloper@ volcanomail.com wrote in message
          news:54774824.0 310031329.40c9b 5df@posting.goo gle.com...
          Is a temporary table really more expensive than a regular table?
          Actually, I prefer a temporary table, because my application serves
          multiple users simultaneously. I am concerned about concurrency
          issues that arise if I use
          just a regular table.
          >
          Speaking of which, what if I use a temporary BLOB rather than a
          temporary table? I am trying to do this now, but I can't figure out
          how to get the modified BLOB object back to Java after the PLSQL block
          has finished executing.
          >
          I do:
          >
          BLOB bl = BLOB.createTemp orary(db,true,B LOB.DURATION_SE SSION);
          CallableStateme nt plsqlblock = conn.prepareCal l(
          "declare\n" +
          " stuff... \n"+
          "begin\n"+
          " procThatModifie sBLOB(?);\n"+
          "end;\n");
          plsqlblock.setB lob(1, bl);
          plsqlblock.exec ute();
          >
          bl = plsqlblock.getB lob(1); //**** doesn't work.
          >
          How do I retrieve the modified value of "bl" after "plsqlblock "
          finishes executing?
          >
          >
          "Jim Kennedy" <kennedy-down_with_spamm ers@no_spam.com cast.netwrote in
          message news:<Pxffb.485 819$Oz4.329946@ rwcrnsc54>...
          >
          If it works on a regular table then why are you making things more
          expensive
          by putting it in a temp table first? Just get it out of the regular
          table.
          Jim
          >
          "Oracle_Technet " <oracle_technet @yahoo.comwrote in message
          news:c3e04899.0 310022230.799c3 a82@posting.goo gle.com...
          Reason as per my understanding: java front end would be using
          connection pooling, and the session is not bound. so once the back end
          proc gives the output back to front end, and then the front end tries
          to access the blob stored in the global temp table, it will give
          error, as global temp table is session specific. (so rowid not found).
          Same type of errors would be encountered with ref cursors based on
          global temp tables.
          So, don't use Global Temporary tables for returning resultsets to java
          front end.
          Hope this helps.
          >
          JavaDeveloper@v olcanomail.com (Corrine) wrote in message
          news:<54774824. 0309290654.58fb 3f16@posting.go ogle.com>...
          Hi,

          I am creating a global temporary table that is session-specific. I
          insert a BLOB into this table, and then select the BLOB from this
          table into a ResultSet. The ResultSet sees this BLOB object, and I
          am
          able to get the binary input stream from this blob. However, when I
          invoke InputStream.rea d(byte[]) on this input stream, I get the
          following exception:

          java.io.IOExcep tion: ORA-01410: invalid ROWID
          ORA-06512: at "SYS.DBMS_L OB", line 751
          ORA-06512: at line 1


          at oracle.jdbc.dba ccess.DBError.S QLToIOException (DBError.java:6 25)

          at
          oracle.jdbc.dri ver.OracleBlobI nputStream.need Bytes(OracleBlo bInputStream.ja v
          a:179)

          at
          oracle.jdbc.dri ver.OracleBuffe redStream.read( OracleBufferedS tream.java:113)

          at
          oracle.jdbc.dri ver.OracleBuffe redStream.read( OracleBufferedS tream.java:91)
          ...

          Just for clarity, here is basically the code I'm using:

          CallableStateme nt cstmt2 = db.prepareCall( "commit");
          CallableStateme nt cstmt = db.prepareCall( "create global
          temporary
          table temp_table (blobid NUMBER unique, blob_col BLOB) on commit
          preserve rows");
          cstmt.execute() ;
          cstmt.close();
          cstmt2.execute( );
          CallableStateme nt cstmt1 = db.prepareCall( "insert into
          temp_table
          values (1, empty_blob())") ;
          cstmt1.execute( );
          cstmt1.close();
          cstmt2.execute( );
          cstmt2.close();

          CallableStateme nt plsqlblock =
          db.prepareCall( stringThatFills InEmptyBlobInTe mpTable);
          plsqlblock.exec ute();
          plsqlblock.clos e();

          PreparedStateme nt pstmt1 = db.prepareState ment("select blob_col
          from
          temp_table where blobid = 1");
          ResultSet rset = pstmt1.executeQ uery();
          BLOB bl;
          if (rset.next())
          {
          System.out.prin tln("success.") ; //<--- This prints out.
          bl = ((OracleResultS et)rset).getBLO B(1);
          }
          pstmt1.close();

          InputStream bis = bl.getBinaryStr eam();
          int numBytes = 0;
          byte[] theBytes = new byte[appropriateLeng th];
          numBytes = bis.read(theByt es); ///*******EXCEPTIO N HAPPENS
          HERE!!!!


          I would also like to mention that when I change temp_table to be
          just
          a regular table, everything works correctly.

          What's the problem, and how do I fix it?

          Thanks,

          Corrine
          You don't need a temporary table. In Oracle readers don't block readers or
          writers and writers don't block readers. This type of programming is often
          seen in SQLServer because of the lack of concurrency. Using a regular table
          you will not see concurrency issues in Oracle.
          Jim


          Comment

          Working...