OdbcDataReader + LONG RAW problem
Hi,
I'm trying to get picture data stored in long raw field with odbcdatareader (with CommandBehaviour.SequentialAccess).
But when i read data, GetBytes function always return 0.
What can i do ?
while(dr.Read())
retval = dr.GetBytes(0,startIndex,buffer,0,bufferSize);
while(retval == bufferSize)
startIndex += bufferSize;
retval = dr.GetBytes(0,startIndex,buffer,0,bufferSize);
}
I haven't worked specifically with long raw and JDBC.
There is a bug in the Oracle 9i OCI driver that limits the insert size of long raw to 50k. Are you using the OCI driver? Can you try the thin driver?
Oracle has a 32k limit on the server side internal driver for long raw.
I have seen documentation on a 32k limit returned when accessing / inserting long raw in PL/SQL. Is it possible that the message is being returned from the SP rather then as an issue with the driver (i.e. maybe you could stream a long raw > 32k directly and not go through an SP)?
Do you have to use long raw? Can you use one of the LOB types? If you can move to an LOB type you should.
Not as much help as you probably need. If you have to stay with long raw, perhaps someone with JDBC long raw experience will see your post and help out.
Similar Messages
-
Problem in converting Long Raw to Varchar2
Hi
I need to analyze the contents of a 'Long Raw ' field to proceed further. In an attempt to do that, using the following code, I could not see the data in a readable format.Kindly Help...
create or replace procedure lr2vc1 (lv_id number) is
c1 long raw;
note_varchar2 varchar2(32000);
begin
select value into c1 from Test_table where id=lv_id; /*value is the Long Raw field*/
note_varchar2 := utl_raw.cast_to_varchar2(c1);
insert into lr2vc (prid,lrvalue) values (lv_id, note_varchar2);
commit;
--dbms_output.put_line(c1);
end;
Thanks
SandeepWhats wrong with the answer given here?:
<br>
Problem while converting Long Raw data to Varchar2 -
Problem getting a LONG RAW value
Hi,
I cannot make this code work:
OracleCommand cmd = new OracleCommand("ABC$MYPACKAGE.GetLogo", new OracleConnection(_constr));
cmd.CommandType = CommandType.StoredProcedure;
cmd.InitialLONGFetchSize = -1;
cmd.Connection.Open();
cmd.BindByName = true;
OracleParameter p = cmd.Parameters.Add("parameter_no1", OracleDbType.Decimal);
p.Value = 10549923;
p.Direction = ParameterDirection.Input;
p = cmd.Parameters.Add("parameter_no2", OracleDbType.Decimal);
p.Value = 656427;
p.Direction = ParameterDirection.Input;
p = cmd.Parameters.Add("RETCURSOR", OracleDbType.RefCursor);
p.Direction = ParameterDirection.Output;
OracleDataReader reader = cmd.ExecuteReader();
if (reader.Read())
... code here ...
cmd.Connection.Close();
It keeps throwing AccessViolationException when executing the reader.Read() statement.
The only value the ref cursor returns is a LONG RAW, but it fails even before I try to access that through the reader. I cant seem to find the problem!
regards,
CarlCan you try out changing ExecuteReader to ExecuteNonQuery and get OracleDataReader from the OracleRefCursor stored in p.Value?
Something like -
cmd.ExecuteNonQuery();
OracleRefCursor cur = p.Value;
OracleDataReader reader = cur.GetDataReader(); -
We have a LONG RAW column.
JDev mapped it to Raw and LONGVARBINARY as SQL type.
Reading data (even huge amounts) works alright, but when we try to insert or update we get:
Data size bigger than max size for this type
I did some reading on the internet and found that I had to stream data into JDBC which Raw apparently cannot handle.
So how can I solve this?
And please, don't just write "Create a domain". I tried. It's not that easy for me. It should be a bit more specific.
Thanks in advance!
SaschaYou not only have to create a Domain but also implement either BlobDomainInterface or one of it's subclassed interfaces.
See oracle.jbo.domain.BlobDomainInterface (source in bc4jdomorcl-src.zip) for an example of how various interface methods are implemented.
When a domain implements BlobDomainInterface, it's called during load/save Entity data to setup it's transaction context (if it needs to during load) and to save it's content into the db using the given transaction context.
These interfaces are written with the assumption that there's an oracle.sql.* class that knows how to use transaction to fetch data using SQL-locator objects. In this case I believe you will need to extend the domain from oracle.sql.RAW class. -
How to read LONG RAW data from one table and insert into another table
Hello EVERYBODY
I have a table called sound with the following attributes. in the music attribute i have stored some messages in the different language like hindi, english etc. i want to concatinate all hindi messages and store in the another table with only one attribute of type LONG RAW.and this attribute is attached with the sound item.
when i click the play button of sound item the all the messages recorded in hindi will play one by one automatically. for that i'm doing the following.
i have written the following when button pressed trigger which will concatinate all the messages of any selected language from the sound table, and store in another table called temp.
and then sound will be played from the temp table.
declare
tmp sound.music%type;
temp1 sound.music%type;
item_id ITEM;
cursor c1
is select music
from sound
where lang=:LIST10;
begin
open c1;
loop
fetch c1 into tmp; //THIS LINE GENERATES THE ERROR
temp1:=temp1||tmp;
exit when c1%notfound;
end loop;
CLOSE C1;
insert into temp values(temp1);
item_id:=Find_Item('Music');
go_item('music');
play_sound(item_id);
end;
but when i'm clicking the button it generates the following error.
WHEN-BUTTON-PRESSED TRIGGER RAISED UNHANDLED EXCEPTION ORA-06502.
ORA-06502: PL/SQL: numeric or value error
SQL> desc sound;
Name Null? Type
SL_NO NUMBER(2)
MUSIC LONG RAW
LANG CHAR(10)
IF MY PROCESS TO SOLVE THE ABOVE PROBLEM IS OK THEN PLESE TELL ME THE SOLUTION FOR THE ERROR. OTHER WISE PLEASE SUGGEST ME,IF ANY OTHER WAY IS THERE TO SOLVE THE ABOVE PROBLEM.
THANKS IN ADVANCE.
D. PrasadYou can achieve this in many different ways, one is
1. Create another VO based on the EO which is based on the dest table.
2. At save, copy the contents of the source VO into the dest VO (see copy routine in dev guide).
3. commiting the transaction will push the data into the dest table on which the dest VO is based.
I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
if by table you mean a DB table, then no, you can have a VO based on multiple EOs which will do DMLs accordingly.Thanks
Tapash -
Processing LONG RAW in the trigger
I'm currently using Oracle 7.3.4.x. I'd like to perform in the
update trigger of LONG RAW column the copy of that value to
another table. Since the :new and :old is prohibited in triggers
and you cannot defined variables as LONG RAW data type in the
trigger I couldn't work out any solution to this problem.
Any one get any idea how to do that?
Thanks,
Mariusz.Hi!
You will not be able to do "select * from ..." from a table with a LONG column. However you will be able to do a select successfully by using the individual column name(s). The other thing is, in order to see the full content of the LONG column you will have to do do "set long nnnnn" where nnnnn represents the maxumum length of the values in the LONG column.
Hope that helps.
null -
How to insert data from file into long raw field using utl_file?
I try to insert binary data from a file (under AIX 4.3.3) into a LONG
RAW field (Oracle 8.1.6).
First, I retrieve the data from the file like this:
DECLARE
FileHandle = UTL_FILE.FILE_TYPE;
myVariable LONG RAW;
FileHandle := UTL_FILE.FOPEN ;('prj/oracle/admin/MARTIJN/udump',
'MyFile.ATT', 'R');
UTL_FILE.GET_LINE (FileHandle, myVariable);
UTL_FILE.FCLOSE(FileHandle);
INSERT INTO myTable(DUMMYFIELD) VALUES(myVariable);
Where DUMMYFIELD of table myTable is of type LONG RAW.
The GET_LINE statement crashes on Oracle Error ORA-6502: Numeric of
Value error: hex to raw conversion error.
What do I do wrong?
Do I use the right method to retrieve information from a file and put
it into a long raw field, should I try it another way?
Any help greatly appreciated,
Martijn RutteZarina,
To clarify your problem, you have a script node contaning your Matlab code. Are you then using the standard LV functions to load in your data from a file and pass it into the script node?
Regards
Tristan -
Importing a file containing long raw data
I have got a .dmp file which was exported from an oracle 8i database & contains a long raw column.Now, when i try to import this file in to oracle 9i database, the import says,
C:\>imp
Import: Release 9.2.0.1.0 - Production on Sat Aug 20 14:51:03 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Username: sys@mydb2 as sysdba
Password:
Connected to: Personal Oracle9i Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
Import file: EXPDAT.DMP > invoice_content.dmp
Enter insert buffer size (minimum is 8192) 30720>
Export file created by EXPORT:V08.01.07 via conventional path
Warning: the objects were exported by TPSYSADM, not by you
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
export client uses US7ASCII character set (possible charset conversion)
export server uses US7ASCII NCHAR character set (possible ncharset conversion)
List contents of import file only (yes/no): no >
Ignore create error due to object existence (yes/no): no >
Import grants (yes/no): yes >
Import table data (yes/no): yes >
Import entire export file (yes/no): no >
Username: tpsysadm
Enter table(T) or partition(T:P) names. Null list means all tables for user
Enter table(T) or partition(T:P) name or . if done:
. importing TPSYSADM's objects into SYS
Import terminated successfully without warnings.
Now, when i query from the sys user, i dont find any object with the name invoice_contents.
Can any 1 help me out of the above problem.
Thanks in advance.The import seems OK, but it also seems that no rows have been imported, maybe no tables. What is the result of :
SQL> select owner, table_name from dba_tables where table_name like '%INVOICE%';
BTW, is the name invoice_content or invoice_contents ?
If the query does not give result, then try to check the content of your dmp file
C:\> imp user/password@db file=invoice_content.dmp full=y show=y
Paul -
Long Raw Picture not showing in adf
I have used following servlet to show long raw picture. the problem is in line
Blob blob = rs.getBlob("PLAN_PIC");
The oracle column is Long Raw and in ADF table this column shows as Raw. I have tried to use Raw class but could not identify proper functions. For example I used Long blob=rs.getLong("PLAN_PIC"); it is ok but then how to get its buffered binary stream because getBinaryStream() does not work for long. I also tried to use to_blob function to convert long raw column to blob but it also gives ora-0932 error. The same table shows picture in oracle form and also Dot Net developer showed the same picture. Kindly help.
//servlet code is
public class imageservlet extends HttpServlet {
// private static final String CONTENT_TYPE = "text/html; charset=UTF-8"; ( I checked both content types but nothing)
private static final String CONTENT_TYPE = "image/jpg; charset=utf-8";
public void init(ServletConfig config) throws ServletException {
super.init(config);
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
response.setContentType(CONTENT_TYPE);
String imageId = request.getParameter("id");
// String imageId="4000";
OutputStream os = response.getOutputStream();
Connection conn = null;
try {
Context ctx = new InitialContext();
//Datasource as defined in <res-ref-name> element of weblogic.xml
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/DYEDS");
conn = ds.getConnection();
PreparedStatement statement =
conn.prepareStatement("SELECT plan_no, plan_pic " +
"FROM tblplanpics " +
"WHERE plan_no = ?");
// statement.setInt(1, new Integer(imageId));
statement.setString(1,imageId);
ResultSet rs = statement.executeQuery();
if (rs.next()) {
Blob blob = rs.getBlob("PLAN_PIC");
BufferedInputStream in =
new BufferedInputStream(blob.getBinaryStream());
int b;
byte[] buffer = new byte[10240];
while ((b = in.read(buffer, 0, 10240)) != -1) {
os.write(buffer, 0, b);
os.close();
} catch (Exception e) {
System.out.println(e);
} finally {
try {
if (conn != null) {
conn.close();
} catch (SQLException sqle) {
System.out.println("SQLException error");The answers are the same as in your other thread https://forums.oracle.com/thread/2591893 about this issue.
Timo -
Memory Leak with Oracle ODBC Driver for Long Raw columns
Oracle version : 8.1.7
Platform : Win2K
Oracle ODBC Driver version : 8.0.1.7.5.0.0
Hi,
I've got an Oracle database upgraded from
V8.0.5 to V8.1.7 which has a table having one long raw +
normal columns. I was able to observe distinct memory
leaks (approx 80K) when using ODBC interface calls (thro C++ code) that referenced a combination of normal & long raw columns in a select statement. However, this leak was not observed when only normal columns were present in the
select statement. Is there any known restriction for using
long raw columns with other columns? Or do long raw columns have a known memory leak problem thro ODBC?
Thanks!
Regards
SanchayanDid you ever get an answer on this issue?
Thanks in advance -
Does oracle 8i can be able to export and import long raw data?
Hi freinds,
i m trying to export a user schema that includes emp_photo a long raw, it got exported with out errors (oracle 7 doesnt). when im tryuing to import it is getting failed, does it cant be imported? or this is becz of some other problems.
thanks in advanceHi,
Could you list the error messages that you are getting when you try to do an import. -
Moving Long Raw from one table to another
How to copy the record stored in a table which has Long Raw column and insert into another table
The follwoing code is giving a numeric or value error
declare
BLOB_ID NUMBER(12);
BLOB_FILE LONG RAW;
Cursor c1 is select
BLOB_ID ,
BLOB_FILE from test ;
Begin
Open c1;
Loop
Fetch c1 into
blob_id,
blob_file;
Exit when c1%notfound;
End loop;
Close c1;
End;I don't see any problem with your code. Are you sure that the type of your variables matches the datatypes of blob_id and blob_file?
sql>create table test (blob_id number(12), blob_file long raw);
Table created.
sql>create table test_copy (blob_id number(12), blob_file long raw);
Table created.
sql>insert into test values (1, utl_raw.cast_to_raw(lpad('x', 40, 'x')));
1 row created.
sql>declare
2 blob_id test.blob_id%type;
3 blob_file test.blob_file%type;
4 cursor c1 is
5 select blob_id, blob_file from test;
6 begin
7 open c1;
8 loop
9 fetch c1 into blob_id, blob_file;
10 exit when c1%notfound;
11 insert into test_copy values (blob_id, blob_file);
12 end loop;
13 close c1;
14 commit;
15 end;
16 /
PL/SQL procedure successfully completed.
sql>select * from test_copy;
BLOB_ID B
1 7 -
How to show long raw picture in adf jsp
Pictures are stored in long raw column in oracle database. I have followed to show picture based on servlet to retrieve image from blob column but to no success. Kindly help.
Thanks for helping.
I have already used following servlet but no picture. I think problem is in specific line because image is in Long Raw instead of Blob..
Blob blob = rs.getBlob("PLAN_PIC");
Image Servlet
public class imageservlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=UTF-8";
public void init(ServletConfig config) throws ServletException {
super.init(config);
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
response.setContentType(CONTENT_TYPE);
String imageId = request.getParameter("id");
// String imageId="4000";
OutputStream os = response.getOutputStream();
Connection conn = null;
try {
Context ctx = new InitialContext();
//Datasource as defined in <res-ref-name> element of weblogic.xml
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/DYEDS");
conn = ds.getConnection();
PreparedStatement statement =
conn.prepareStatement("SELECT plan_no, plan_pic " +
"FROM tblplanpics " +
"WHERE plan_no = ?");
// statement.setInt(1, new Integer(imageId));
statement.setString(1,imageId);
ResultSet rs = statement.executeQuery();
if (rs.next()) {
// Blob blob = rs.getBlob("PLAN_PIC");
Blob blob = rs.getBlob("PLAN_PIC");
BufferedInputStream in =
new BufferedInputStream(blob.getBinaryStream());
int b;
byte[] buffer = new byte[10240];
while ((b = in.read(buffer, 0, 10240)) != -1) {
os.write(buffer, 0, b);
os.close();
} catch (Exception e) {
System.out.println(e);
} finally {
try {
if (conn != null) {
conn.close();
} catch (SQLException sqle) {
System.out.println("SQLException error"); -
Hi,
I am using developer 6i with oracle 10.2.0.4 on win 2008.
I created a table as below:
create table image_table (filename varchar2(255) primary key, image long raw);
i created a trigger in forms to upload a image and store the link in the database. The image is stored in a directory.
The image link is saved in image_table.
But when i query the table, i get the below error
SQL> select * from image_table;
ERROR:
ORA-00932: inconsistent datatypes
no rows selected
When i query the table in TOAD, i get the output as
FILENAME, IMAGE
ateeq, (BLOB)
Please suggest how to solve this problem.
Thanks,the LONG and LONG RAW datatype have been deprecated in Oracle 8.0, in 1998, so 14 years ago!
Is there any sound reason why you can't use a BLOB?
a LONG ROW column can not be displayed directly, so a
select * from image_table
where one of the columns is a LONG RAW is expected not to work,
and if you would have read documentation (which you never do, I remember you from previous doc questions), you would have known and not have asked Yet Another Redundant Question!
Sybrand Bakker
Senior Oracle DBA -
Load image file into a LONG RAW column via SQL*Loader
Does anyone know how to load a image file into a LONG RAW column via SQL*Loader?
Thanks
-Hsing-Hua-Are you trying to import the image on the client into Oracle lite, or from the server end into the main oracle database for download to the client?
On our system images are loaded into the the oracle lite database (10g R1 at the moment) on the client (DELL X50 PDA's) into a BLOB (Not LONG RAW) column using Java (relatively standard functionality in Java) as this is what our application software is written in.
From the server end, we do not at the moment load images as such, but we do load the application software into the database for deployment of new versions to the clients (the DMC/DMS updates we have found very unreliable), and the technique should be the same for images. Again the file is imported into a BLOB column.
NOTE a column defined as BLOB on the main Oracle database appears as a LONG VARBINARY on the client Oracle lite database, but the synchronisation process handles the conversion with no problem.
To import into a BLOB column on the server try the following
1) you will need to create a DIRECTORY (CREATE DIRECTORY command) within the database, pointing at a directory on the database server (or accessible from it). This is needed for the file location.
CREATE OR REPLACE DIRECTORY PDA_FILE_UPLOAD AS '/pdaapps/jar/'
NOTE create directory needs to be run as SYSTEM
2) define your table to hold the image and other data. Our tables is
SQL> desc pda_applications
Name Null? Type
ID NOT NULL NUMBER(12)
PDAAT_CODE NOT NULL VARCHAR2(10)
VERSION NOT NULL NUMBER(5,2)
PART_NO NOT NULL NUMBER(3)
FILE_OBJECT BLOB
DEPLOY_APPLICATION_YN NOT NULL VARCHAR2(1)
3) copy the image (or in our case a .jar file) to the database server directory specified in step 1
4) the actual import is done using a DBMB_LOB procedure
PROCEDURE pr_load_file
Module Name : pr_load_file
Description : Main call. Create a new pda_applications record, and import the specified file into it
Version History:
Vers. Author Date Reason
1.0 G Wilkinson 03/02/2006 Initial Version.
(PA_VERSION IN NUMBER
,PA_FILENAME IN VARCHAR2
,PA_PDAAT_CODE IN VARCHAR2
,PA_PART_NO IN NUMBER DEFAULT 1
,PA_DEPLOY IN VARCHAR2 DEFAULT 'Y')
IS
l_FileLocator BFILE;
l_blobLocator BLOB;
l_seq NUMBER;
l_location VARCHAR2(20);
no_params EXCEPTION;
call_fail EXCEPTION;
BEGIN
-- Throw error if required details not present
IF pa_version IS NULL
OR pa_filename IS NULL
OR pa_pdaat_code IS NULL THEN
RAISE no_params;
END IF;
-- Initialize the BLOB locator for writing. Note that we have
-- to import a blob into a table as part of a SELECT FOR UPDATE. This locks the row,
-- and is a requirement for LOADFROMFILE.
SELECT pdaa_id_seq.nextval
INTO l_seq
FROM dual;
-- First create the application record (file is imported by update, not insert
INSERT INTO pda_applications
(ID,PDAAT_CODE,VERSION,PART_NO,FILE_OBJECT,DEPLOY_APPLICATION_YN)
VALUES (l_seq,pa_pdaat_code,pa_version,pa_part_no,EMPTY_BLOB(),pa_deploy);
-- Lock record for update to import the file
SELECT file_object INTO l_blobLocator
FROM pda_applications
WHERE id=l_seq
FOR UPDATE;
-- Initialize the BFILE locator for reading.
l_FileLocator := BFILENAME('PDA_FILE_UPLOAD', pa_filename);
DBMS_LOB.FILEOPEN(l_FileLocator, DBMS_LOB.FILE_READONLY);
-- Load the entire file into the character LOB.
-- This is necessary so that we have the data in
-- character rather than RAW variables.
DBMS_LOB.LOADFROMFILE(l_blobLocator, l_FileLocator
,DBMS_LOB.GETLENGTH(l_FileLocator)
,src_offset => 1);
-- Clean up.
DBMS_LOB.FILECLOSE(l_FileLocator);
-- Create download records for each user associated with the application for sending to the PDA's
-- to install the software
IF pa_deploy = 'Y' then
IF fn_deploy (pa_pdaa_id => l_seq
,pa_pdaat_code => pa_pdaat_code) != 'SUCCESS' THEN
RAISE call_fail;
END IF;
END IF;
EXCEPTION
WHEN no_params THEN
pkg_appm.pr_log_message( pa_mdl_name => g_module_name
, pa_mdl_version => fn_get_body_version
, pa_error_code => SQLCODE
, pa_location => l_location
, pa_text => 'Missing parameters'
, pa_severity => 'E'
WHEN OTHERS THEN
DBMS_LOB.FILECLOSE(l_FileLocator);
pkg_appm.pr_log_message( pa_mdl_name => g_module_name
, pa_mdl_version => fn_get_body_version
, pa_error_code => SQLCODE
, pa_location => l_location
, pa_text => SQLERRM
, pa_severity => 'E'
END pr_load_file;
I hope this may be of some help
Maybe you are looking for
-
How do I make my quick look persist when it loses focus?
Before I reinstalled my computer (from 10.6 to 10.6, so no change in version), my quick look windows would stay open when I changed focus to other applications. This made it easy to quick look a PDF while typing up an email in gmail, for example. Now
-
How to Move a file from one Directory to another directory.
Hi All i am having a Java standlone Application reqiurements are 1---->Connection pool To be Created. 2---->Using Thread to read Multiple Files Simulatneously. 3----->After Reading Those file I have to Move it to another folder. Plz help me.If possib
-
Acrobat X (which I have on Windows 7 as part of CS6) stopped working after being updated by Adobe Application Manager yesterday - it just won't open. I uninstalled and reinstalled it; it opened once and then stopped working again. I've also started g
-
Can't get the Navigation Bar re-opened
I have accidentally closed or hidden the most important Bar: The one with the Back and Forth buttons. File View etc Have been trying everything....please call me if possible to talk me through this........xxx-xxx-xxxx [email protected]
-
By the way, forgot to tell...
looking through /tmp/81502.log after applying the patch, i found some mv: <my $ORACLE_HOME>/bin/lsnrtcl : No such file or directory, and some other similars though it wrote me that the patch was successfull still, any ideas?