Solved

inserting data into remote SQL server.

Posted on 2013-11-22
8
1,195 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 73

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 73

Expert Comment

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

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 73

Accepted Solution

by:
sdstuber earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to return an OUT parameter from and ORACLE 3 68
Read only access to a Procedure in oracle? 4 65
Get the parent node - XMLTYPE 9 73
dbms_crypto.decrypt   errors out 6 31
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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 set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

770 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