views:

341

answers:

4
+1  Q: 

SQL*Loader problem

I am getting an error SQL*Loader-606, which means:

The synonym specified in the INTO TABLE clause in the SQL*Loader control file specifies a remote object via a database link. Only a synonym for an existing local table can be specified in the INTO TABLE clause.

Is there any way we can insert into remote table using SQL*Loader?

+2  A: 

create table temp_table as select * from remote_table@remote_db where 1 = 2;

load using sql*loader into temp_table;

insert into remote_table@remote_db select * from temp_table;

Robert Merkwürdigeliebe
+1 Most SQL*Loader problems are easier to solve in SQL. That's why External Tables are such a boon.
APC
@Robert .Thanks for the suggestion but if the table is a huge table! then dont you think that this will take a hell lot of time to insert and also to create and this should be perfomed regularly in the form of a process,so this i am afraid will be a feasible solution or not!!
Vijay Sarathi
Then why don't you let sqlldr connect to the remote databasesqlldr username/password@tnsaliasYou have acces to the remote database using the tnsalias otherwise the databaselink would not work
Robert Merkwürdigeliebe
Yes ,Robert I am doing the same but the problem is as i mentioned above INTO TABLE clause will take a synonym which is for a local existing table:)
Vijay Sarathi
@crasher: Robert is saying don't connect to your local database and hit the other database over a database link... hit the other database directly. SQL*Loader can connect to remote databases directly, it just can't insert into a database link. Connect directly to remote_db. Don't use your local database as an intermediary.
Rob
+1  A: 

Run SQL Loader on the server that has the table?

Must be a reason why not, but this seems the simplest to me.

Paul James
I dont have an access to that server to run nythg on it.:)
Vijay Sarathi
+5  A: 

Because you are on 10g you can use External Tables instead of SQL Loader.

Setting up an External Table is easy. Find out more.

To get the External Table to pick up a new file (which you may need to do because you have a repeating process), do this:

alter table your_ext_table_name location ('<newfile.name>')
/

Then you can do this:

insert into whatever_table@remote_db
    select * from your_ext_table_name 
/

This avoids two lots of DML. External tables are not as fast as a well-tuned SQL*Loader process, but that will be trivial compared to the network traffic tax (which is unavoidable in your scenario).

APC
A: 

If you couldn't use external tables (eg because the data file is on a client machine rather than on the database server), you can insert into a view on the remote object.

For example

create database link schema1 connect to schema1 identified by schema1 using 'XE';
create view schema1_test_vw as select * from test@schema1;

load data
 infile *
 append
 into table schema1_test_vw
 ( id POSITION(1:4) INTEGER)
begindata
1001
1002
1003

succeeded on my XE test. For a view all the column sizes,datatypes etc are fixed on the local schema so sqlldr doesn't have a problem.

Gary