Insert a blob in remote database using dblink
i have a view (it has a BLOB column) from where i need to select the records. After selecting i need to insert it into a synonym in the remote database through a db link.
if i execute the procedure i get error; ora-22992--cannot use LOB locators selected from remote table. My code is
INSERT INTO [email protected]
SELECT PID,RNO, PTYPE,blob_field
FROM view;
I dont wish to creat a temporary table and still wish to perform the above function.
So is there any method to do this. I tried with DBMS_LOB.APPEND but it didnt work out. Any solution will be greatly appreciated.
Thanks,
-Nitin
i have a view (it has a BLOB column) from where i need to select the records. After selecting i need to insert it into a synonym in the remote database through a db link.
if i execute the procedure i get error; ora-22992--cannot use LOB locators selected from remote table. My code is
INSERT INTO [email protected]
SELECT PID,RNO, PTYPE,blob_field
FROM view;
I dont wish to creat a temporary table and still wish to perform the above function.
So is there any method to do this. I tried with DBMS_LOB.APPEND but it didnt work out. Any solution will be greatly appreciated.
Thanks,
-Nitin
Similar Messages
-
Oracle VPD on Remote database using DBLINk
Hi All,
How can i apply row level security on a table that is available in another database using DBlink
we have two databases PDSSM and EVTA, and i would like to apply row level security on a table in EVTA from a schema in PDSSM using dblink. MXODSADM IS A SCHEMA IN EVTA AND MXEMBARGO IS A SCHEMA IN PDSSM. there is a dblink(EVTA.GMM.COM) between mxembargo and mxodsadm.
begin
dbms_rls.add_policy (
object_schema => 'MXODSADM',
object_name => 'vehicle_retail_sale',
policy_name => ' MXEMBARGO_EVTA_POLICY',
function_schema =>'MXEMBARGO',
policy_type => dbms_rls.SHARED_CONTEXT_SENSITIVE,
--policy_type => dbms_rls.STATIC,
policy_function => ' MXEMBARGO_EVTA_POLICY.MXEMBARGO_EVTA_PREDICATE',
statement_types => 'select, insert,update,delete',
update_check => TRUE,
enable => TRUE,
static_policy => TRUE
end;
I am a complete Database person and i need to do this in my application, can anyone provide me how can i do this using dblink.wojpik wrote:
hello
I have one short question to you.
Is that possible to create view at remote database using dblink? Following syntax returns error
create view ViewName@DbLinkDame (ColumnName) as
(select 1 from dual )
"ORA-00905:missing keyword"
Is that possible at all?
And particulary - is that possible when remote database is MSSQL and I am using heterogeneous services?
I really appreciate your help
best regards
Wojtek
Edited by: wojpik on Oct 21, 2009 3:59 AMI doubt you would be able to fire any ddl through database link. You have to connect to remote database to run any ddl even if it is Oracle or some other database.
Regards
Anurag -
How can I access a database remote without using dblink, synonyms,aliases?
My store procedure access a remote tables using dblink, synonyms, alias, but by business company requirenments I nedd to use another data base access method. My PL/SQL statement looks like
select c.cus_id, c.cus_name, p.bankaccno
into v_cus_id, v_cus_name, v_bankaccno
from customer c, payment@finantial p
where c.cus_id = p.cus_id
Are any method else to connect to several remote databases concurrently?
If Yes, plase say me how is it, or tell me where do I obtain some examples, or any documentation.
Edited by: user518321 on Apr 21, 2009 1:58 PM
Ok, But I must not use any of these data base access method, metioned: dbliks, aliases, synonyms.
Edited by: user518321 on Apr 21, 2009 2:05 PM
Ok, It is enough for now, I am surprised for the response time and for their arguments, thanks a lot.
Edited by: user518321 on Apr 21, 2009 2:50 PMIf you want to access a table in a remote database using SQL, you will need a database link. It would be exceptionally odd for the business to require that you access a remote database and to prohibit the use of database links. What is the business reason for that combination?
If you want to look into rather more esoteric solutions, you could load a JDBC driver for the remote database, write a Java stored procedure that queries the remote table using that JDBC driver, and then cobble together some PL/SQL that joins the two result sets. You won't be able to reference the remote table in SQL and the solution won't scale well as data volumes increase and you'll be writing a whole lot of code to manually join tables together, but it does avoid database links. Of course, whatever concerns lead to the ban on database links would probably apply to loading a JDBC driver into the database and writing Java stored procedures to access the remote database, but since you haven't explained the reasoning behind the restrictions, we're just guessing.
Justin -
Problem with inserting two BLOBs into a table using setBinaryStream
DBMS 9.2.0.1.0, Oracle JDBC driver 10.1.0.2.0
The following code insert in one INSERT two BLOBs
into two columns using PreparedStatement.setBinaryStream(). When the size of the of at least one blob exceeds
some limit (? 2k, 4k ?), the values are swapped and
inserted into wrong columns.
Please, is this a problem in JDBC driver?
====================================================
import java.io.ByteArrayInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
* Test - two BLOBs swapped problem.
* If size of the blob is larger that some treshold, they are swapped in the database.
public class BlobSwapTest {
private static Connection getConnection() throws SQLException {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException cnfe) {
throw new SQLException("ClassNotFoundException: " + cnfe.getMessage());
return DriverManager.getConnection("jdbc:oracle:thin:@//HOST:1521/DB", "USER", "PSWD");
private static void createTable() throws SQLException {
Connection conn = getConnection();
Statement stmt = null;
try {
stmt = conn.createStatement();
try {
stmt.execute("DROP TABLE BlobTest2");
} catch (SQLException e) {
System.err.println("Table BlobTest2 was not deleted: " + e.getMessage());
stmt.execute(
"CREATE TABLE BlobTest2 ("
+ " pk VARCHAR(512), "
+ " blob BLOB, "
+ " blobB BLOB, "
+ " PRIMARY KEY (pk)"
+ ")"
} finally {
try {
if (stmt != null) stmt.close();
} finally {
conn.close();
public static void main(String[] args) throws SQLException {
createTable();
Connection conn = getConnection();
PreparedStatement pstmt = null;
try {
conn.setAutoCommit(false);
pstmt = conn.prepareStatement("INSERT INTO BlobTest2 VALUES (?,?,?)");
final int size = 5000; // change the value to 500 and the test is OK
byte[] buf = new byte[size];
byte[] buf2 = new byte[size];
for (int i = 0; i < size; i++) {
buf = 66;
buf2 = 88;
pstmt.setString(1, "PK value");
pstmt.setBinaryStream(2, new ByteArrayInputStream(buf), size);
pstmt.setBinaryStream(3, new ByteArrayInputStream(buf2), size);
pstmt.executeUpdate();
conn.commit();
} finally {
if (pstmt != null) pstmt.close();
conn.close();
====================================================See my response in the JVM forum.
-
Issue of inserting greek characters into Oracle database using ICAN505
Hi All,
We are currently facing an issue of inserting greek characters into Oracle database using ICAN505.
We receive a file containing greek characters.The values from the file should be inserted into the database.We are reading the file using file OTD with default encoding.
The file can contain english characters too other than greek characters.
The database NLS_CHARACTERSET is AL32UTF8.
When I insert using an insert statement directly ,the values get inserted properly into the DB table.
Inserting the same values using code results in improper characters getting inserted into the table in the database.
Please help....
Thanks in advance !!Globalization forum?
Globalization Support
It works for SQL Developer, which does not depend on NLS_LANG, so I suspect a problem with your NLS settings. -
How to access remote database using applet
hi all,
I want to know how to access remote database using applet,
Please help me anybody.
Regards
JesuIf the database is on a public server, you probably can't access it directly (security wise). You can make your applet talk to a server-side application, which makes the database calls on behalf of the applet. But even in an intranet environment this setup is often preferable, because you don't need to distribute a JDBC driver to all your clients.
-
Lock-ups while inserting to a remote database using a dblink
Our application runs across multiple instances of Oracle 8i - 8.1.6.
Throughout the day we run some batch processes to transfer data across these instances using dblinks. Ocassionally the process locks up and further investigation shows that the server from which we are pushing information out seems to have executed an insert statement on a remote instance (insert into test_table@tst_dblink select * from local_table) and is waiting for a return from the remote server while the remote instance seems to be hanging too. Oracle does not return any error but simply waits forever for the statement to finish.
If anybody has experienced this before can you please share any information you may have on 1. how to prevent this from happening or 2. How to make oracle give up on the transaction, roll it back and raise an error?
Thanks a lot....Well, certainly we need more info to fix the problem! couple of "system states" on both the machines when the job is hanging would help. couple of "stack trace" of the shadow process will also help. please call local oracle support with the system state and stack trace.
Sounds like the job is hanging on some resource (lock,enque,latch,io...). oracle doesn't give up for few resources, like waiting on ST,latch, io etc. we have to kill the offending process if we want!!
just my 2 cents :)
G -
Replicating clobs and blobs in a remote database across dblink
9iR2
When creating a materialized view in a warehouse pointing to a remote table in an OLTP environment, I got this error when trying to replicate a table with 3 clobs.
ORA-22992: cannot use LOB locators selected from remote tables
So, how does Oracle recommend replicating Blobs and Clobs in a remote database/warehouse? Evidently using materialized views doesnt work.MV replication is obsolete.
Move to 10gR2 and use Streams. -
Display BLOB from remote database
Context: We are offloading documents (pdf) from our OLTP database to a dedicated 'output database.' These documents must be displayed from the application on our OLTP database using a database link. Various posts show that querying a BLOB from a remote database can best be implemented using a query on the remote table and an insert on a local (temporary) table. So far, so good. The idea is to display this BLOB using wpg_docload.download_file.
BUT:
When trying to display the pdf from this global temporary table an error occurs:
ORA-14453: attempt to use a LOB of a temporary table, whose data has already been purged
When trying to display from a normal table and issuing a rollback after wpg_docload.download_file results in another error:
ORA-22922: nonexistent LOB value
When trying to display from a normal table and not removing the record in any way, its works fine. Only I now have a garbage collection issue, because the remote date remain in my local (preferably temporary) table.
It seems to me that mod_plsql needs an active session to display my pdf.
Does anyone have an explanation for this behaviour and maybe a solution for my problem?
Environment:
local: 10.2.0.4.0
remote: 11.1.0.7.0
pdf size: ca. 150kB
code used:
PROCEDURE show_doc (p_nta_id IN NUMBER
,p_sessie IN NUMBER
IS
t_lob BLOB;
t_lob2 BLOB := empty_blob();
t_mime VARCHAR2(100);
BEGIN
-- copy BLOB into local global temp table
INSERT INTO mvs_tmp_notaprint_bestanden
npv_nta_id
, npv_npe_sessie
, mime_type
, bestand
) -- from remote table
SELECT npd.npv_nta_id
,npd.npv_npe_sessie
,npd.mime_type
,npd.bestand
FROM mvs_notaprint_bestanden@marc npd
WHERE npd.npv_nta_id ; = p_nta_id
AND npd.npv_npe_sessie = p_sessie
-- show BLOB from local global temp table
SELECT t.bestand
, t.mime_type
INTO t_lob
, t_mime
FROM mvs_tmp_notaprint_bestanden t
WHERE t.npv_nta_id ; = p_nta_id
AND t.npv_npe_sessie ; = p_sessie
t_lob2 := t_lob; -- buffer BLOB
owa_util.mime_header(t_mime , FALSE );
owa_util.http_header_close;
wpg_docload.download_file(t_lob2);
END show_doc;Andrew,
thank you, the 'preserve rows' did the trick.
Every query from a browser (even in the same browser session) is a new Oracle session, so the copied records in the global temporary table are gone after the page is displayed.
Am I correct in assuming that each call from the browser results in a new Oracle session? I did a few tests and found for each call a different sessionid.
Sincerly,
Arne Suverein
Edited by: Arne Suverein on Aug 18, 2009 3:35 PM -
Inserting Multiple Images into oracle database using JDBC
I wanted to insert multiple images into database using JDBC by reading it from the file... and i am passing photos.txt(my text file) as an input parameter... I have inserted all the values into the database except for the image part... this is my content of photos.txt file and i have copied all the images into the folder
*" C:\\photos "*
*1,in1.jpg,108,19,in-n-out*
*2,in2.jpg,187,21,in-n-out*
*3,in3.jpg,308,41,in-n-out*
*4,in4.jpg,477,52,in-n-out*
*5,in5.jpg,530,50,in-n-out*
and i want to store in1.jpg,in2.jpg,in3.jpg,in4.jpg,in5.jpg into the oracle databse using JDBC.... i have tried a lot using BLOB column.... and i have created my table as
CREATE TABLE PHOTO(
ID NUMBER NOT NULL PRIMARY KEY ,
Name BLOB,
X DOUBLE PRECISION,
Y DOUBLE PRECISION,
Tags VARCHAR2(40)
try { // for restaurant System.out.println();System.out.println();System.out.println(); System.out.print(" Creating Statement for Photo...\n"); stmt2 = con.createStatement (); stmt2.executeUpdate("delete from PHOTO"); stmt2.executeUpdate("commit"); PreparedStatement stmt3 = con.prepareStatement ("INSERT INTO PHOTO VALUES (?, ?, ?, ?, ?)"); System.out.print(" Create FileReader Object for file: " + inputFileName1 + "...\n"); FileReader inputFileReader2 = new FileReader(inputFileName1); System.out.print(" Create BufferedReader Object for FileReader Object...\n"); BufferedReader inputStream2 = new BufferedReader(inputFileReader2); String inLine2 = null; String[] tokens; // String[] imageFilenames = {"c:\\photos\\in1.jpg","c:\\photos\\in2.jpg","c:\\photos\\in3.jpg","c:\\photos\\in4.jpg","c:\\photos\\in5.jpg", // "c:\\photos\\in6.jpg","c:\\photos\\in7.jpg","c:\\photos\\in8.jpg","c:\\photos\\in9.jpg","c:\\photos\\in10.jpg","c:\\photos\\arb1.jpg","c:\\photos\\arb2.jpg", // "c:\\photos\\arb3.jpg","c:\\photos\\arb4.jpg","c:\\photos\\arb5.jpg","c:\\photos\\den1.jpg","c:\\photos\\den2.jpg","c:\\photos\\den3.jpg", // "c:\\photos\\den4.jpg","c:\\photos\\den5.jpg","c:\\photos\\hop1.jpg","c:\\photos\\hop2.jpg","c:\\photos\\hop3.jpg","c:\\photos\\hop4.jpg","c:\\photos\\hop5.jpg"}; File file = new File("C:\\photos\\in1.jpg"); \\ ( Just for example ) FileInputStream fs = new FileInputStream(file); while ((inLine2 = inputStream2.readLine()) != null) { tokens= inLine2.split(","); st2 = new StringTokenizer(inLine2, DELIM); stmt3.setString(1, tokens[0]); stmt3.setBinaryStream(2, fs, (int)(file.length())); stmt3.setString(3, tokens[2]); stmt3.setString(4, tokens[3]); stmt3.setString(5, tokens[4]); stmt3.execute(); //execute the prepared statement stmt3.clearParameters();
As i am able to enter one image file by above code in1.jpg in to the oracle database.... but i am not able to insert all the image file in to the database.....do tell me what should i do.... and can you give me the example on the basis of the above code of mine...
do reply as soon as possible..jwenting wrote:
that depends. Putting the images in BLOBs prevents the file locations stored in the database from getting out of synch with the filesystem when sysadmins decide to reorganise directory structures or "archive" "old" files that noone uses anyway.True, but it really comes down to a business decision (cost-benefit analysis). If you have the bucks, the expertise, and the time, go with the Blobs, otherwise go with the flat files. -
Connect to remote database using ODBC
I am new to TimesTen and I would like some help connecting to remote timesten database using ODBC.
I followed all the instructions in the manual to setup (like logical server and all). but, when I try to connect using "connect dsn=myRemoteDSN" command, it does not work. It gives me this error: 7001: User authentication failed
It is asking me for username and password but I dont know how to setup username and password. Looked all over the internet and I could not find any relevant posts. I have already tried "unchecking" the authentication, but it still asks me for username and password.thanks for your help. I did not realize that that I turned on ACL. creating a user and then granting the needed permissions did the trick.
I now have another problem. I use windows platform and .NET 2.0 (C#) to connect to remote timesten database. The driver provided by timesten (as part of installation) does not seem to support ADO.NET. I get "driver does not support this function" exception when I try to insert data into a table. Ironically, it does insert the data successfully, but still generates the exception. I looked at various forums.. everyone seems to have the same problem, but have not had any solution yet?
Could you let me know if you encountered this issue before and how you might have resolved it?
Many thanks
Murthy -
Unable to create publication item for remote database using db link
The mobile repository is in instance A.
I have to access and sync data from a table in remote database instance B.
I have run the consolidator_rmt.sql script in instance B under schema_B. I have created a private fixed user db link in instance A under schema_A to access schema_B's tables. I then created a synonym test_B for table test_B in schema_B using the DB link.
While creating publication item for test_B using MDW, the column list for test_B appears blank. Has anyone encountered this problem and what is the solution.
Thanks for your help.
Rosa.Hello Pruthvi ,
See these threads
Uninstalling MaxDB
Work process Ended.
Thanks
Chandran -
Connecting to Remote Database using Debian w/Oracle XE
Hello.
I have managed to install Oracle XE on a Debian box.
I am trying to connect to a remote server located on my network.
I am using the following connection string:
# sqlplus <User>/<Password>@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<IP>)(PORT=1521)))(CONNECT_DATA=(SID=<SID>)))'
However, I was given both a SID and a Service_name.
I tried connecting with both.
Is it possible to parametrize both? I checked and the remote server is up, and that is the existing port.
Thanks a lot!user603592 wrote:
Hello.
I have managed to install Oracle XE on a Debian box.
I am trying to connect to a remote server located on my network.
I am using the following connection string:
# sqlplus <User>/<Password>@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<IP>)(PORT=1521)))(CONNECT_DATA=(SID=<SID>)))'
However, I was given both a SID and a Service_name.
I tried connecting with both.
Is it possible to parametrize both? yes, see below
bcm@bcm-laptop:~$ sqlplus -h
SQL*Plus: Release 11.2.0.1.0 Production
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Use SQL*Plus to execute SQL, PL/SQL and SQL*Plus statements.
Usage 1: sqlplus -H | -V
-H Displays the SQL*Plus version and the
usage help.
-V Displays the SQL*Plus version.
Usage 2: sqlplus [ [<option>] [{logon | /nolog}] [<start>] ]
<option> is: [-C <version>] [-L] [-M "<options>"] [-R <level>] [-S]
-C <version> Sets the compatibility of affected commands to the
version specified by <version>. The version has
the form "x.y[.z]". For example, -C 10.2.0
-L Attempts to log on just once, instead of
reprompting on error.
-M "<options>" Sets automatic HTML markup of output. The options
have the form:
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
[ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
-R <level> Sets restricted mode to disable SQL*Plus commands
that interact with the file system. The level can
be 1, 2 or 3. The most restrictive is -R 3 which
disables all user commands interacting with the
file system.
-S Sets silent mode which suppresses the display of
the SQL*Plus banner, prompts, and echoing of
commands.
<logon> is: {<username>[/<password>][@<connect_identifier>] | / }
[AS {SYSDBA | SYSOPER | SYSASM}] [EDITION=value]
Specifies the database account username, password and connect
identifier for the database connection. Without a connect
identifier, SQL*Plus connects to the default database.
The AS SYSDBA, AS SYSOPER and AS SYSASM options are database
administration privileges.
<connect_identifier> can be in the form of Net Service Name
or Easy Connect.
@[<net_service_name> | [//]Host[:Port]/<service_name>]
<net_service_name> is a simple name for a service that resolves
to a connect descriptor.
Example: Connect to database using Net Service Name and the
database net service name is ORCL.
sqlplus myusername/mypassword@ORCL
Host specifies the host name or IP address of the database
server computer.
Port specifies the listening port on the database server.
<service_name> specifies the service name of the database you
want to access.
Example: Connect to database using Easy Connect and the
Service name is ORCL.
sqlplus myusername/mypassword@Host/ORCL
The /NOLOG option starts SQL*Plus without connecting to a
database.
The EDITION specifies the value for Session Edition.
<start> is: @<URL>|<filename>[.<ext>] [<parameter> ...]
Runs the specified SQL*Plus script from a web server (URL) or the
local file system (filename.ext) with specified parameters that
will be assigned to substitution variables in the script.
When SQL*Plus starts, and after CONNECT commands, the site profile
(e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile
(e.g. login.sql in the working directory) are run. The files may
contain SQL*Plus commands.
Refer to the SQL*Plus User's Guide and Reference for more information.
bcm@bcm-laptop:~$ -
How to store file content in BLOB field MySql database using java
Hi!
i want to store the file content in a BLOB field in MySql database using java.
Please help me out..........
thanx in advance...
byei stored images in db, and retrieved them. like that cant i store pdf file in db, and retrieve it back using oracle db?
Plz help me out how to put a file in db. i need complete code. thanks in advance. -
How to insert date into ms access database using sql query in servlet
sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
or either the system date is inserted with query .
plz help me
thanxbhavishya wrote:
sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
or either the system date is inserted with query .
plz help me
thanxAnd that SQL statement is another reason to use PreparedStatement. I assume bname and sname are input from some form? Well, if that's the case, simply inserting them into SQL by simple String concatenation is just begging for all sorts of problems. What if there is an apostrophe in the entry? Broken Statement. Worse, it's a wide open invitation to an SQL Injection attack.
Maybe you are looking for
-
Oracle Portal 11.1.1.6 with OAM 11.1.1.5
Hi All, I have the following customer requirement. Oracle Portal 11.1.1.6 which is deployed on WebLogic Server 10.3.6 Oracle Access Manager 11.1.1.5.0 Oracle Internet Directory 11.1.1.6.0 The customer wants to have Single Sign On for the Oracle Porta
-
How to get rid of extra data in character buffers for key and data
Hi - Using the C API, I am using a cursor to just pull all the key/value pairs from a database. Here is the relevant code: /* Initialize key/data structures. */ memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); key.flags = DB_DBT_MALLOC;
-
Any way to configure time machine?
Hello: I have heard that there is a way to configure time machine so you can specify how often to back up the hard drive. Any thoughts? I am not sure why Apple chose not to allow the user to specify the time interval. Right now, I have 150 GB on my h
-
Passing output to a method, I'm lost!
I want to put all of my "output" including the returns on the three Temp functions in my method DisplayTemperatures, but I'm stuck and don't know how to do this. Please help import javax.swing.*; import java.text.DecimalFormat; public class Temp {
-
Some quesitons related to J2ME
Hi, I have few questions regarding J2ME development. My aim is to build a midlet application which can installed on any mobile phone. Following are my questions: 1) The application icon size is different for different mobile phones and I dont see any