473,395 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.read(byte[]) on this input stream, I get the
following exception:

java.io.IOException: ORA-01410: invalid ROWID
ORA-06512: at "SYS.DBMS_LOB", line 751
ORA-06512: at line 1
at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBEr ror.java:625)

at oracle.jdbc.driver.OracleBlobInputStream.needBytes (OracleBlobInputStream.java:179)

at oracle.jdbc.driver.OracleBufferedStream.read(Oracl eBufferedStream.java:113)

at oracle.jdbc.driver.OracleBufferedStream.read(Oracl eBufferedStream.java:91)
...

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

CallableStatement cstmt2 = db.prepareCall("commit");
CallableStatement 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();
CallableStatement cstmt1 = db.prepareCall("insert into temp_table
values (1, empty_blob())");
cstmt1.execute();
cstmt1.close();
cstmt2.execute();
cstmt2.close();

CallableStatement plsqlblock =
db.prepareCall(stringThatFillsInEmptyBlobInTempTab le);
plsqlblock.execute();
plsqlblock.close();

PreparedStatement pstmt1 = db.prepareStatement("select blob_col from
temp_table where blobid = 1");
ResultSet rset = pstmt1.executeQuery();
BLOB bl;
if (rset.next())
{
System.out.println("success."); //<--- This prints out.
bl = ((OracleResultSet)rset).getBLOB(1);
}
pstmt1.close();

InputStream bis = bl.getBinaryStream();
int numBytes = 0;
byte[] theBytes = new byte[appropriateLength];
numBytes = bis.read(theBytes); ///*******EXCEPTION 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
Jul 19 '05 #1
4 13643
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.

Ja***********@volcanomail.com (Corrine) wrote in message news:<54**************************@posting.google. 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.read(byte[]) on this input stream, I get the
following exception:

java.io.IOException: ORA-01410: invalid ROWID
ORA-06512: at "SYS.DBMS_LOB", line 751
ORA-06512: at line 1
at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBEr ror.java:625)

at oracle.jdbc.driver.OracleBlobInputStream.needBytes (OracleBlobInputStream.java:179)

at oracle.jdbc.driver.OracleBufferedStream.read(Oracl eBufferedStream.java:113)

at oracle.jdbc.driver.OracleBufferedStream.read(Oracl eBufferedStream.java:91)
...

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

CallableStatement cstmt2 = db.prepareCall("commit");
CallableStatement 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();
CallableStatement cstmt1 = db.prepareCall("insert into temp_table
values (1, empty_blob())");
cstmt1.execute();
cstmt1.close();
cstmt2.execute();
cstmt2.close();

CallableStatement plsqlblock =
db.prepareCall(stringThatFillsInEmptyBlobInTempTab le);
plsqlblock.execute();
plsqlblock.close();

PreparedStatement pstmt1 = db.prepareStatement("select blob_col from
temp_table where blobid = 1");
ResultSet rset = pstmt1.executeQuery();
BLOB bl;
if (rset.next())
{
System.out.println("success."); //<--- This prints out.
bl = ((OracleResultSet)rset).getBLOB(1);
}
pstmt1.close();

InputStream bis = bl.getBinaryStream();
int numBytes = 0;
byte[] theBytes = new byte[appropriateLength];
numBytes = bis.read(theBytes); ///*******EXCEPTION 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

Jul 19 '05 #2
"Oracle_Technet" <or************@yahoo.com> wrote in message
news:c3**************************@posting.google.c om...
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.

Ja***********@volcanomail.com (Corrine) wrote in message

news:<54**************************@posting.google. 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.read(byte[]) on this input stream, I get the
following exception:

java.io.IOException: ORA-01410: invalid ROWID
ORA-06512: at "SYS.DBMS_LOB", line 751
ORA-06512: at line 1
at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBEr ror.java:625)

at oracle.jdbc.driver.OracleBlobInputStream.needBytes (OracleBlobInputStream.jav
a:179)
at oracle.jdbc.driver.OracleBufferedStream.read(Oracl eBufferedStream.java:113)
at oracle.jdbc.driver.OracleBufferedStream.read(Oracl eBufferedStream.java:91) ...

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

CallableStatement cstmt2 = db.prepareCall("commit");
CallableStatement 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();
CallableStatement cstmt1 = db.prepareCall("insert into temp_table
values (1, empty_blob())");
cstmt1.execute();
cstmt1.close();
cstmt2.execute();
cstmt2.close();

CallableStatement plsqlblock =
db.prepareCall(stringThatFillsInEmptyBlobInTempTab le);
plsqlblock.execute();
plsqlblock.close();

PreparedStatement pstmt1 = db.prepareStatement("select blob_col from
temp_table where blobid = 1");
ResultSet rset = pstmt1.executeQuery();
BLOB bl;
if (rset.next())
{
System.out.println("success."); //<--- This prints out.
bl = ((OracleResultSet)rset).getBLOB(1);
}
pstmt1.close();

InputStream bis = bl.getBinaryStream();
int numBytes = 0;
byte[] theBytes = new byte[appropriateLength];
numBytes = bis.read(theBytes); ///*******EXCEPTION 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
Jul 19 '05 #3
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.createTemporary(db,true,BLOB.DURATION_SESSION );
CallableStatement plsqlblock = conn.prepareCall(
"declare\n"+
" stuff... \n"+
"begin\n"+
" procThatModifiesBLOB(?);\n"+
"end;\n");
plsqlblock.setBlob(1, bl);
plsqlblock.execute();

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

How do I retrieve the modified value of "bl" after "plsqlblock"
finishes executing?
"Jim Kennedy" <kennedy-down_with_spammers@no_spam.comcast.net> wrote in message news:<Pxffb.485819$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" <or************@yahoo.com> wrote in message
news:c3**************************@posting.google.c om...
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.

Ja***********@volcanomail.com (Corrine) wrote in message

news:<54**************************@posting.google. 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.read(byte[]) on this input stream, I get the
following exception:

java.io.IOException: ORA-01410: invalid ROWID
ORA-06512: at "SYS.DBMS_LOB", line 751
ORA-06512: at line 1
at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBEr ror.java:625)

at oracle.jdbc.driver.OracleBlobInputStream.needBytes (OracleBlobInputStream.jav
a:179)
at oracle.jdbc.driver.OracleBufferedStream.read(Oracl eBufferedStream.java:113)
at oracle.jdbc.driver.OracleBufferedStream.read(Oracl eBufferedStream.java:91) ...

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

CallableStatement cstmt2 = db.prepareCall("commit");
CallableStatement 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();
CallableStatement cstmt1 = db.prepareCall("insert into temp_table
values (1, empty_blob())");
cstmt1.execute();
cstmt1.close();
cstmt2.execute();
cstmt2.close();

CallableStatement plsqlblock =
db.prepareCall(stringThatFillsInEmptyBlobInTempTab le);
plsqlblock.execute();
plsqlblock.close();

PreparedStatement pstmt1 = db.prepareStatement("select blob_col from
temp_table where blobid = 1");
ResultSet rset = pstmt1.executeQuery();
BLOB bl;
if (rset.next())
{
System.out.println("success."); //<--- This prints out.
bl = ((OracleResultSet)rset).getBLOB(1);
}
pstmt1.close();

InputStream bis = bl.getBinaryStream();
int numBytes = 0;
byte[] theBytes = new byte[appropriateLength];
numBytes = bis.read(theBytes); ///*******EXCEPTION 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


Jul 19 '05 #4
"Corrine" <Ja***********@volcanomail.com> wrote in message
news:54**************************@posting.google.c om...
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.createTemporary(db,true,BLOB.DURATION_SESSION );
CallableStatement plsqlblock = conn.prepareCall(
"declare\n"+
" stuff... \n"+
"begin\n"+
" procThatModifiesBLOB(?);\n"+
"end;\n");
plsqlblock.setBlob(1, bl);
plsqlblock.execute();

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

How do I retrieve the modified value of "bl" after "plsqlblock"
finishes executing?
"Jim Kennedy" <kennedy-down_with_spammers@no_spam.comcast.net> wrote in message news:<Pxffb.485819$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" <or************@yahoo.com> wrote in message
news:c3**************************@posting.google.c om...
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.

Ja***********@volcanomail.com (Corrine) wrote in message

news:<54**************************@posting.google. 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.read(byte[]) on this input stream, I get the
> following exception:
>
> java.io.IOException: ORA-01410: invalid ROWID
> ORA-06512: at "SYS.DBMS_LOB", line 751
> ORA-06512: at line 1
>
>
> at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBEr ror.java:625)
>
> at

oracle.jdbc.driver.OracleBlobInputStream.needBytes (OracleBlobInputStream.jav a:179)
>
> at

oracle.jdbc.driver.OracleBufferedStream.read(Oracl eBufferedStream.java:113)
>
> at

oracle.jdbc.driver.OracleBufferedStream.read(Oracl eBufferedStream.java:91)
> ...
>
> Just for clarity, here is basically the code I'm using:
>
> CallableStatement cstmt2 = db.prepareCall("commit");
> CallableStatement 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();
> CallableStatement cstmt1 = db.prepareCall("insert into temp_table > values (1, empty_blob())");
> cstmt1.execute();
> cstmt1.close();
> cstmt2.execute();
> cstmt2.close();
>
> CallableStatement plsqlblock =
> db.prepareCall(stringThatFillsInEmptyBlobInTempTab le);
> plsqlblock.execute();
> plsqlblock.close();
>
> PreparedStatement pstmt1 = db.prepareStatement("select blob_col from > temp_table where blobid = 1");
> ResultSet rset = pstmt1.executeQuery();
> BLOB bl;
> if (rset.next())
> {
> System.out.println("success."); //<--- This prints out.
> bl = ((OracleResultSet)rset).getBLOB(1);
> }
> pstmt1.close();
>
> InputStream bis = bl.getBinaryStream();
> int numBytes = 0;
> byte[] theBytes = new byte[appropriateLength];
> numBytes = bis.read(theBytes); ///*******EXCEPTION 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
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jim Garrison | last post by:
Scenario: 1) Create a GLOBAL TEMPORARY table and populate it with one (1) row. 2) Join that table to another with about 1 million rows. The join condition selects a few hundred rows. ...
2
by: Yannick Turgeon | last post by:
Hello all, I'm using SS2K on W2K. Brieffing: Many months ago, I created a stored procedure only used by those with admin rights in SS. Now, someone else (without admin rights) has to run it....
3
by: vsaraog | last post by:
Hi everybody, I asked the following question but didn't get any reply. If anyone knows something about the problem, then please reply since I am really in a bind. Here is the question... I...
7
by: fintudet | last post by:
Hello. During some experimentation with DB2 decimal numbers representations, I have discovered very unexpected behaviour of the global temporary table. Consider this example. Such I had...
2
by: chettiar | last post by:
I am creating a procedure A which is creating a global temporary table DECLARE GLOBAL TEMPORARY TABLE session.temp (Service CHAR(2), CustomerServiceTypeId INTEGER) WITH REPLACE ON COMMIT PRESERVE...
1
by: Kburton | last post by:
Is it possible to create a temporary table and fill it with data in single declare statement? Example: Declare global temporary table session.tmp1 AS (select tid,fid,name from <table> where...
5
by: Rahul B | last post by:
Hi, I have very little knowledge about creating Procedures/functions in DB2. When i tried to create the test function like CREATE FUNCTION GET_TEST (P_TEST_ID INTEGER, P_SEL_OR_SORT...
1
by: Ragianand | last post by:
Hi All, I have created a stored procedure which populates a global emporary table...Now i want to write a function which returns a view that contains the data from the global temporary table.Can...
4
by: Corrine | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.