Solved

inserting data into remote SQL server.

Posted on 2013-11-22
8
1,425 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-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 74

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 74

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

630 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