Solved

inserting data into remote SQL server.

Posted on 2013-11-22
8
1,087 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
Comment Utility
you may have to retrieve the local values first then insert them.

bulk operations if possible, iterate if necessary
0
 

Author Comment

by:FutureDBA-
Comment Utility
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-
Comment Utility
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
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
are you doing a commit when you run the pl/sql block?
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 22

Expert Comment

by:Steve Wales
Comment Utility
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-
Comment Utility
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
Comment Utility
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-
Comment Utility
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.

Join & Write a Comment

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
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…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now