BLOB in SQL
Hi.
I have created a table as
table name : m_tab
fields :
n_name varchar2(10);
n_suggestion varchar2(2000);
n_post_reply varchar2(2000);
n_read_reply varchar2(2000);
Here the size of varchar2 is large.
Is it adv to use BLOB declaration and whether the BLOB
Can anyone tell me the adv and disadv of using BLOB and its funcationalities with a simple eg..
Thanks
Gaya3
with varchar2, in Oracle9.2, you can have up to 4000 bytes. If you want to store a large data, then CLOB/BLOB would be a better option. With CLOB/BLOB, you can go up to 4GB. If you have a limited data, up to 4000 bytes, then I would advise you to stick with varchar2
Similar Messages
-
Insert into blob(image) sql server 2000
hello
i want enter one image for example fish.jpg into blob into
sql server 2000 plz help me...http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/LOBSample.zip
this contains samples for using blob with oracle. use the idea for your code. -
Reading BLOB from SQL Server 2005 using DB Link from Oracle 10g
Hi All,
I am trying to read a table's data from SQL Server 2005 using ODBC DB Link created in Oracle 10g (10.2.0.3/4) database. I am not using oracle gateway.
I am able read all data except for the BLOB data from SQL server 2005. It gives error given below when I try to execute query SELECT * from T_TRANSACTION_DATA@sdeslink inside a stored procedure:
ORA-22992: cannot use LOB locators selected from remote tables
Kindly help how to read BLOB from SQL server 2005 inside Oracle 10g.
Best Regards!
IrfanIrfan,
If you can read the blob data using 10.2 HSODBC then there should be no problem using the 11g gateway.
I recommend you download the latest version which is 11.2.0.3 available from My oracle Support as -
Patch 10404530: 11.2.0.3.0 PATCH SET FOR ORACLE DATABASE SERVER
This is a full version and does not need a previous version to have bene installed. When installing it needs to be in a completlely separate ORACLE_HOME from the existing 11.2 install.
For the Ora-22992 problem have a look at this note in My Oracle Support -
Ora-22992 has a workaround in 10gR2 (Doc ID 436707.1)
Regards,
Mike -
Hi,
Is it possible to compare blob in SQL statement?
Example:
Table1 (id number
image long raw);
Table2 (name varchar2
pic long raw);
select id, name from table1, table2
where image = picHi,
Try the following and see if it works :
I have TEXT in the LONG RAW column and not image
files.
Method I
You can use PL/SQL to check if the 2 Long RAW Columns are
identical or not :
NOTE :- PL/SQL however has a limitation of processing
data size less than 32k in size. If the
Long Raw column exceeds 32k in size then PL/SQL
cannot be used.
SQL> desc temp9;
Name Null? Type
ID NUMBER
COL1 LONG RAW
SQL> desc temp9a;
Name Null? Type
ID NUMBER
COL1 LONG RAW
SQL> @t
Id = 1, Long Raw is not the same
Id = 2, Long Raw is the same
PL/SQL procedure successfully completed.
SQL> select id from temp9;
ID
1
2
SQL> get t
1 Set ServerOutput On Size 999999;
2 Declare
3 CURSOR c1 Is
4 Select id, col1
5 from temp9;
6 xCol1 Temp9a.Col1%Type;
7 BEGIN
8 For x In c1 Loop
9 Select col1
10 Into xCol1
11 From temp9a
12 Where id = x.id;
13 If ( x.col1 = xCol1) Then
14 Dbms_Output.Put_Line ('Id = ' || x.id || ', Long Raw is the same');
15 Else
16 Dbms_Output.Put_Line ('Id = ' || x.id || ', Long Raw is not the same');
17 End If;
18 End Loop;
19 END;
20* /
Method II
You can create a Database function for the above script and use it within
your SQL .
-- Shailender Mehta -- -
BLOB
suppose i want to insert image into SQL server table.....what would be table design ?
should i write
IMAGE varchar(50); // its wrong ..so whats right to put a blob in a column ?Blobs are a pain. First off there's nothing about
them in the SQL99 standard, so every database handles
them differently.
Worse, whoever wrote JDBC specification doesn't seem
to have understood how they work.
A BLOB/CLOB is functionally very different from a
varable text/binary field, because all that goes into
the database record itself is some kind of reference
number. BLOBs are stored outside the tables
structure, and not normally through SQL. There can be
several references to the same BLOB from different
records and databases don't seem to keep track of use
counts, so you have to delete them explicitly.
For example in the database I'm using at the moment,
Postgresql, The reference is declared as an "OID" and
it's set in a preparedStatement with a setBlob
method. Saddly there's no legitimate way to create a
new Blob object. I've known people create an record
with an empty blob first, then read and update it in
order to get a Blob object.
Some JDBC drivers, you can use a setOutputStream
method, but the specification is pretty vague.Sir,
While an excellent rant I'm not sure what this has to do with the topic at hand which is how to create a table with a BLOB like column in it in MS-SQL. The OP question really has nothing to with Java at all but we try not let such trivialities stop us.
Good rant though. Have thought the same things myself many a time.
Sincerely,
Slappy -
Hello,
I hope you can help me :-) !!!!!!
I have a EJB, in a metod of EJB i would update a object blob in a database. So i get a old blob from database by
resultSet rs = ****query****
((oracle.jdbc.oracleSet) rs ).getBLOB(1);
but throws ClassCastException on the cast oracleSet......
i try withthis code:
ResultSet rs = ****query****
Blob b = rs.getBlob(1);
OutputStream out = b.setBinaryStream(1);
but throws java.sql.SQLException: Funzione non supportata
Why?????
what's can i do?
help me!!!!!!!
thanksHello,
I hope you can help me :-) !!!!!!
I have a EJB, in a metod of EJB i would update a object blob in a database. So i get a old blob from database by
resultSet rs = ****query****
((oracle.jdbc.oracleSet) rs ).getBLOB(1);
but throws ClassCastException on the cast oracleSet......
i try withthis code:
ResultSet rs = ****query****
Blob b = rs.getBlob(1);
OutputStream out = b.setBinaryStream(1);
but throws java.sql.SQLException: Funzione non supportata
Why?????
what's can i do?
help me!!!!!!!
thanks -
Using blobs with SQL*Net 8
Hello,
Can someone please help me get oriented in the following:
Clients have Oracle Forms Developer 6i installed on 100 machines. This is from 1996 I think. It comes with SQL*Net 8.
They want a simple utility that uploads a file into a blob field on the remote database.
I already developed the utility thinking that they have Oracle 9i2 installed - so I used OCCI. This is not a possibility with the old technology they are actually using..
So what is the place to start?
Thank you!!
davidYou can try with PRO-C
-
Importing oracle.sql.BLOB through SQL Loader
Hello,
Currently the system we have creates .sql files and executes them. This takes a long time, so we're attempting to change to using SQL Loader. The one problem I'm having that I can't seem to fix is finding out how to imitate the behavior of this SQL statement through SQL Loader:
INSERT INTO KRSB_QRTZ_BLOB_TRIGGERS (BLOB_DATA,TRIGGER_GROUP,TRIGGER_NAME)
VALUES (oracle.sql.BLOB@515263,'KCB-Delivery','PeriodicMessageProcessingTrigger')
I tried creating a lobfile and placing the text oracle.sql.BLOB@515263 within it this way
INTO TABLE KRSB_QRTZ_BLOB_TRIGGERS
WHEN tablename = 'KRSB_QRTZ_BLOB_TRIGGERS'
FIELDS TERMINATED BY ',' ENCLOSED BY '##'
TRAILING NULLCOLS
tablename FILLER POSITION(1),
TRIGGER_NAME CHAR(80),
TRIGGER_GROUP CHAR(80),
ext_fname FILLER,
BLOB_DATA LOBFILE(ext_fname) TERMINATED BY EOF
However, as expected, it merely loaded the text "oracle.sql.BLOB@515263" into the database. So does anyone have any ideas of how to imitate that insert statement through SQL Loader? The only information I have available is the string "oracle.sql.BLOB@515263", no other files or anything to aid with actually getting the binary data.
When the .sql file is run with that insert statement in it, a 1.2kb BLOB is inserted into the database versus a 22 byte BLOB that contains nothing useful when done through SQL Loader.
AlexMy preference is DBMS_LOB.LOADFROMFILE
http://www.morganslibrary.org/reference/dbms_lob.html
did you try it? -
How to convert CLOB to BLOB with SQL Developer migration wizard?
Hi,
According to our requirement, we need to only migrate data from SQL Server 2008 to Oracle 11. I use the SQL Developer 3.0.04 migration wizard to do it.
I do migration from SQL Server (database name: SCDS41P2) to Oracle (User name: HCDS41P2).
My migration steps are as below: (I need to modify the target schema, so I add the steps 2) and step 3) )
1) Do migration by SQL Developer migration wizard;
2) Remove the Converted Database Objects node from migration project;
3) Re-do convert by SQL Developer migration wizard (contains changing the target schema);
When do step 1), the DBO_SCDS41P2 user is created automatically. CLOBTOBLOB_SQLDEVELOPER procedure is also created in this user.
I continued to run step 2) and step 3) with online mode. And find the table data which contains BLOB column can be moved into the target table. But from the Logging Page, I can't see the other detailed error info, so that I can't check which tables don't move data successfully.
Could you please tell me where the detail log file (e.g. contains every table's migration status) is if I use the online mode?
Additional, If I use offline mode to do step 3), I found the CLOB data can't be converted into BLOB automatically. Because in the load script (that is oracle_ctl.bat), only copy the source data to the CLOB column. After copy, it don't deal with the converting from CLOB to BLOB.
So could you please tell me how to convert CLOB to BLOB with offline mode?
Thanks so much.Hi,
For your first question about logging - after the migration there will be an entry in the right hand panel for the migration project. If you open this there are various fields that give information about the status of each part of the migration. Does this give you the information you need ?
For the second problem about offline moving blob data have a look at the SQL*Developer documentation -
Oracle® SQL Developer User’s Guide Release 3.0
in the section -
2.2.8.1.4 Populating the Destination Database Using the Data Files
which describes the problem and how to get round it.
Regards,
Mike
Edited by: mkirtley on Aug 12, 2011 10:49 AM -
Create java class/resource from binary blob in SQL statement
Is there a way of creating a java class or resource from a binary blob in the CREATE JAVA CLASS statement? Something like:
CREATE OR REPLACE JAVA CLASS
USING BLOB 'CAFEBABE0000003100120A0004000D08000E07000F0700100100063C696E69743E010003282956010004436F646501000F4C696E654E756D6265725461626C6501000372756E01001428294C6A6176612F6C616E672F537472696E673B01000A536F7572636546696C6501001152657475726E537472696E672E6A6176610C0005000601001F546869732069732061206E657720737472696E67207269676874206865726501000C52657475726E537472696E670100106A6176612F6C616E672F4F626A65637401000F6175726F72615F6F70745F696E666F002100030004000000000002000100050006000100070000001D00010001000000052AB70001B10000000100080000000600010000000100090009000A000100070000001B00010000000000031202B0000000010008000000060001000000030002000B00000002000C00110000004C00000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009705070397050703';
I've tried various combinations of casting & convert functions, all of them give an ORA-29506 error 'Invalid query derived from USING clause', and nothing useful is gained from google about this. Is there a way of specifying the class binary in this way?You can load Java classes into the database, then create a PL/SQL procedure or function in the database that calls that Java class.
This leaves you with a standard PL/SQL procedure/function which you can call from Oracle Forms.
Have a look at the database documentation on how to load a Java class: http://download.oracle.com/docs/cd/A91202_01/901_doc/java.901/a90210/toc.htm -
hi all,
I am trying to save an image (blob) into oracle. When i try this i am getting following error.
java.sql.SQLException: ORA-01465: invalid hex number
BLOB blob = BLOB.createTemporary(con , false, BLOB.DURATION_SESSION);
String dir = "C:\\opt\\temp";
File binaryFile = new File(dir+"/"+filename);
FileInputStream instream = new FileInputStream(binaryFile);
OutputStream outstream = blob.setBinaryStream(1L);
int size = blob.getBufferSize();
byte[] buffer = new byte[size];
int length = -1;
while ((length = instream.read(buffer)) != -1)
outstream.write(buffer, 0, length);
instream.close();
outstream.close();
System.out.println("blob:>>>>>>"+blob);
String sqlText =
"INSERT INTO test_fileupload (filename, blobfile) " +
" VALUES('" + filename + "','" + outstream + "')";
st.executeUpdate(sqlText);
con.commit();In the above Insert statement i tried with "blob" insted of "outstream" still same but when i try with the string "3s34se"
it is inserting into database..
I am new to blob can any one explain me why is like that.
Thanq in adv.
Edited by: Ajayuppalapati on Nov 21, 2008 4:40 PMORA-01465: invalid hex number
[http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=3&t=012434]
[http://forums.sun.com/thread.jspa?threadID=261091&forumID=31] -
i was given a new task at work today and it involves automating datbase results. We are given one record and i have to populate the rest of the database to a given amount of records.
i have this blob and i know its an image and i am trying to retrieve it but the getBlob() is giving me an error. I hope someone can help me.It looks like I have to resort to using an OCIBlobLocator
as I would if not using ANSI Dynamic. I guess I assumed that
since I specify the exact amount I want out and the type to be
raw I wouldn't need the lob-locator. Can anyone tell me why
the code fragment below seg faults rather than returns some
ora/sql error?
I'm trying to retrieve a blob using ANSI Dynamic SQL in a Pro*C application.
However, when I attempt to use FETCH DESCRIPTOR I get a segmentation fault.
The precompiler picks up if the fetch size and the output structure size
don't match, but it seems that they don't actually match according to the
database.
char correctedinb[GAMMA_CHANNELS*4];
rtype = 113;
rsize = GAMMA_CHANNELS*4;
EXEC SQL SET DESCRIPTOR :out_desc VALUE :occurs
TYPE = :rtype,
LENGTH = :rsize,
REF DATA = :correctedinb,
REF INDICATOR = :spectrumind;
occurs++;
EXEC SQL FETCH g INTO DESCRIPTOR :out_desc; -
ClassCastException while inserting in oracle.sql.BLOB
Hi,
I have to insert a blob data in to database . I wrote the code . I'm having a ClassCastException problem in the line oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(st.getConnection(), false,
oracle.sql.BLOB.DURATION_CALL); while trying to store a BLOB value I'm using Oracle 9i. (JDBC classes12.jar).
if I use the method with a dedicated database connection that specifies the driver as oracle.jdbc.driver.OracleDriver there is no problem .
But when I use JBoss to run , I will get ClassCastException
I imagine that somewhere in the code of this method there is a cast of the underlying connection leading to the ClassCastException when used in conjunction with the jboss datasource. The code to save the BLOB is as follows:
String sql = " update test set code = ? where id = ? ";
BLOB newBlob = BLOB.createTemporary(dbcon, false, BLOB.DURATION_CALL);
newBlob.putBytes(1,data.getBytes());
stmt = dbcon.prepareStatement(newsql);
stmt.setBlob(1, newBlob);
stmt.setInt(2, Studid );
stmt.executeUpdate();
stmt.close();Can any one tell me how can I get this code to work with the datasource implementation.
ThanksI think this could be a problem with the class loader . Take a look at this thread It should solve your problem.
http://forum.java.sun.com/thread.jspa?forumID=48&threadID=788715 -
ClassCastException in oracle.sql.BLOB.createTemporary
Hi,
I'm having a ClassCastException problem using the method oracle.sql.BLOB.createTemporary while trying to store a BLOB value (JDBC classes12.jar). The problem is quite clear - if I use the method with a dedicated database connection that specifies the driver as oracle.jdbc.driver.OracleDriver there is no problem - if I use it with an Orion datasource shipped with Oracle IAS10g it gives me a ClassCastException. I imagine that somewhere in the code of this method there is a cast of the underlying connection leading to the ClassCastException when used in conjunction with the Orion datasource. The code to save the BLOB is as follows:
oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(st.getConnection(), false,
oracle.sql.BLOB.DURATION_SESSION);
blob.open(BLOB.MODE_READWRITE);
OutputStream out = blob.getBinaryOutputStream();
try {
out.write((byte[])value);
out.flush();
out.close();
} catch (IOException e) {
throw new SQLException("failed write to blob" + e.getMessage());
blob.close();
((oracle.jdbc.OraclePreparedStatement)(st)).setBLOB(index, blob);
My questions are:
(1) is it possibile to save a BLOB type with a different version of Oracle JDBC without having to rely on the Oracle specific implementation of the JDBC interface (the cast of the PreparedStatement to oracle.jdbc.OraclePreparedStatement is quite ugly and not very portable!).
(2) if not, then how can I get this code to work with the datasource implementation for Oracle IAS.
thanks in advance for any help.
Dara.If you are using OCI driver, you may check whether using thin driver would avoid ClassCastException.
-
Oracle.sql.BLOB ClassCastException
Hi everyone,
I'm trying to put a serialized Java object into Oracle. I am following the example here: http://www.oracle.com/oramag/oracle/01-may/o31asktom.html
Here is my code:
String sql = "begin " +
"insert into rdm_logs (datetime, id, machine, ip_addr, action_code, tablename, comments, " +
"row_before, row_after)" +
"values (sysdate, ?, ?, ?, ?, ?, ?, empty_blob(), empty_blob()) " +
"return row_before into ?; " +
"end;";
CallableStatement stmt = connection.prepareCall(sql);
stmt.setString(1, username);
stmt.setString(2, machine);
stmt.setString(3, ip);
stmt.setString(4, action_code);
stmt.setString(5, table);
stmt.setString(6, comment);
stmt.registerOutParameter(7, java.sql.Types.BLOB);
stmt.executeUpdate();
Object o = stmt.getBlob(7);
// output class name here
System.out.println(o.getClass().toString());
// cast to oracle.sql.BLOB
oracle.sql.BLOB blob = (BLOB) o;The system output is:
class oracle.sql.BLOB
java.lang.ClassCastException: oracle.sql.BLOB
As you can see, the System.out gives oracle.sql.BLOB as the object class type, so why does it throw an exception when I cast it to be the same?
Any help would be appreciated.As you can see, the System.out gives oracle.sql.BLOB as the object
class type, so why does it throw an exception when I cast it to be the same?This can happen if the two BLOB classes have been loaded with two different unrelated class loaders. Even though the names of the classes are the same there are two separate classes.
How to fix this depends... Somehow arrange the JDBC driver to be loaded by the system class loader before any other class loader has a chance to load it?
Maybe you are looking for
-
Mini Display Port to DVI Resolution Not Working Properly Again
hink another EFI Update is in Order, Just used the Mini DisplayPort to DVI Adaptor to a NEC 3090WQxi Monitor and the Max Resolution is only 1600X1200, while my older (Late 2007) Macbook Pro needed an EFI/SMC update for Graphics before it detected the
-
Se14 message : View Does not exist in database
Hi All , I have created view and transported to test system , In the test system i am not able to activate it , the message is that " view does not exists in database ", Is it some thing for the basis to do . Thanks in advance Vinay
-
RUEI 12.1.0.3.0 - Dropdown List Not Showing Correctly in Session Replay
Hello all, While using Session replay, I found out that dropdown boxes/menu does not work in Session replay mode. I am using RUEI to monitor oracle.com Anyone has a similar experience? Care to assist, please? Regards, Nathan Edited by: 959447 on Dec
-
Premiere Pro CC not playing fair with .mov files
I have a CC account and use Premiere Pro on my PC with no issues so far except that the RAM and Graphics card suck. So I decided to run on my laptop running windows 8 rather than 7. AE runs with no issues (so far), but when I use Premiere Pro it does
-
I have a problem with digital audio
Everytime i record with my groovebox into logic 7, i get this pop up menu that says sample rate 48000 reconized..I checked everything and set to 441, groove box, M Audio and Logic and i still get the same thing YIKES!!!! What's wrong with this stupid