473,480 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 13650
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
33601
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
3362
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
3425
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
2285
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
4101
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
13314
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
8797
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
1855
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
466
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
7044
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
6908
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
7087
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6741
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
6944
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
4483
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2985
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
182
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.