Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

inserting data into remote SQL server.

Posted on 2013-11-22
8
Medium Priority
?
1,627 Views
Last Modified: 2014-02-17
insert into cxprddta.RMOTRI@E (select * from rmotri)

Open in new window


Fails, with

SQL Error: ORA-02025: all tables in the SQL statement must be at the remote database
02025. 00000 -  "all tables in the SQL statement must be at the remote database"
*Cause:    The user's SQL statement references tables from multiple databases.
           The remote database is not Oracle V7 or above, and can perform
           updates only if it can reference all tables in the SQL statement.
*Action:

Open in new window


Does anyone know of a work around.

Note: the remote table has fields that cannot be null
0
Comment
Question by:FutureDBA-
  • 4
  • 3
8 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 39669564
you may have to retrieve the local values first then insert them.

bulk operations if possible, iterate if necessary
0
 

Author Comment

by:FutureDBA-
ID: 39669588
I've also tried the following, which does not work either, the block completes, but no data at remote table, my local and remote tables are have identical column names and types.


DECLARE
CURSOR remote_insert IS SELECT * FROM RMOTRI;
BEGIN
FOR rec IN remote_insert LOOP
INSERT INTO cxprddta.rmotri@E (OTRCUSCHN,OTRCUSNUM,OTRSUBCUS,OTRDELDTE,
OTRLODDTE,OTRPCKDTE,OTRRTENUM,OTRSUBRTE,
OTRPURNUM,OTRITMNUM,OTRCOMTYP,OTRSLSTYP,
OTRSEQNUM,OTRTRNQTY,OTRORWQTY,OTRTRNPRC,
OTRORDTYP,OTRDYSSTR,OTRUPCNUM,OTRCUSITM,
OTRUPCTYP,OTRSTATUS,OTRERRMSG,OTRPRCUSR,
OTRPRCDTE,OTRPRCTIM,X_UPID,X_RRNO) 
VALUES (
rec.OTRCUSCHN,rec.OTRCUSNUM,
rec.OTRSUBCUS,rec.OTRDELDTE,
rec.OTRLODDTE,rec.OTRPCKDTE,
rec.OTRRTENUM,rec.OTRSUBRTE,
rec.OTRPURNUM,rec.OTRITMNUM,
rec.OTRCOMTYP,rec.OTRSLSTYP,
rec.OTRSEQNUM,rec.OTRTRNQTY,
rec.OTRORWQTY,rec.OTRTRNPRC,
rec.OTRORDTYP,rec.OTRDYSSTR,
rec.OTRUPCNUM,rec.OTRCUSITM,
rec.OTRUPCTYP,rec.OTRSTATUS,
rec.OTRERRMSG,rec.OTRPRCUSR,
rec.OTRPRCDTE,rec.OTRPRCTIM,
rec.X_UPID, rec.X_RRNO
);
END loop;
END;

Open in new window

0
 

Author Comment

by:FutureDBA-
ID: 39669622
however,
insert into cxprddta.RMOTRI@E values (9007,	10538,	1,	20131128,	20131127,	0,	29,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	1300,	63);

Open in new window



DOES WORK
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 74

Expert Comment

by:sdstuber
ID: 39669696
are you doing a commit when you run the pl/sql block?
0
 
LVL 23

Expert Comment

by:Steve Wales
ID: 39669778
As sdstuber mentioned, did you commit after the PL/SQL block.

From the documentation, this is a restriction on remote calls - the issue is with what they call CALLBACK LINKS:

http://docs.oracle.com/cd/E11882_01/server.112/e11050/majfeat.htm#CIHECAIE

The work around they suggest is exactly what you've done with the PL/SQL block.  If it wasn't committed, it wouldn't appear in the remote database.

You don't say if you're using the Generic ODBC Gateway or the SQL Server specific Gateway, but they but they both say the same thing:

Generic ODBC: http://docs.oracle.com/cd/E11882_01/gateways.112/e12070/feature.htm#ODBCU764
SQL Server: http://docs.oracle.com/cd/E11882_01/gateways.112/e12069/ch3.htm#GMSWN839
0
 

Author Comment

by:FutureDBA-
ID: 39669964
its sql server gateway.. it seems to work, but the performance is a huge issue. on an insert, for me to insert 1200 records it would take me a few seconds,

same insert with the pl/sql block is taking about a minute.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 39670114
did you try bulk operation  (BULK COLLECT local,  FORALL insert )  ?

I've not tried FORALL INSERT across a gateway but if performance is a problem it's worth attempting


if your column name, order,type is the same local and remote then it might look something like this...


DECLARE
    TYPE rmotri_tab IS TABLE OF rmotri%ROWTYPE;

    v_tab rmotri_tab;
BEGIN
    SELECT *
      BULK COLLECT INTO v_tab
      FROM rmotri;

    FORALL i IN v_tab.FIRST .. v_tab.LAST
        INSERT INTO cxprddta.rmotri@e
             VALUES v_tab(i);

    COMMIT;
END;

Open in new window

0
 

Author Comment

by:FutureDBA-
ID: 39670263
doesn't seem to be permitted on remote tables either.


Error report -
ORA-06550: line 10, column 5:
PLS-00739: FORALL INSERT/UPDATE/DELETE not supported on remote tables
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question