1. source database
conn / as sysdba
alter user scott account unlock;
alter user scott identified by vfr45tgb;
conn scott/vfr45tgb
CREATE TABLE MM(M1 VARCHAR2(30) NOT NULL,N2 VARCHAR2(30) NOT NULL,N1 VARCHAR2(30) NOT NULL);
commit;
INSERT INTO mm VALUES(‘test11′,’test12′,’test13′);
commit;
2. destination database
conn / as sysdba
create PUBLIC database link test
connect to scott identified by vfr45tgb
using ‘(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.2.3.15)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)’
commit;
3. SAPgui
Create a transparent table(zdblnkt) via transaction se11 with the same fields as the table in the source database.
4.destination database
conn sapsr3/vfr45tgb
#check the structure of zdblnkt and mm@test
desc zdblinkt
desc mm@test
drop table zdblnkt.
create view zdblnkt as select * from mm@test;
or
CREATE SYNONYM zdblnkt_DL for mm@test;
create view zdblnkt as select * from zdblnkt_DL;
commit;
5.SAPgui
Check the contents of the table zdblnkt via transaction se16.
Test the operation to the remote database table by following ABAP program.
***********************************************
REPORT Z_DBLINK_TEST MESSAGE-ID 00.
TABLES zdblnkt.
DATA: result TYPE p LENGTH 8 DECIMALS 2,
oref TYPE REF TO cx_root,
TEXT TYPE string.
DATA: itab like zdblnkt OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
TRY .
SELECT * FROM zdblnkt INTO TABLE itab.
CATCH CX_SY_OPEN_SQL_DB INTO oref.
text = oref->get_text( ).
ENDTRY.
IF NOT TEXT IS INITIAL.
MESSAGE E398 with ’Connect Error’.
ENDIF.
LOOP AT itab.
WRITE: itab-mm, ’ ‘, itab-n2, ’ ‘, itab-n1 , /.
ENDLOOP.
clear itab.
itab-mm = ’testx1xz’.
itab-n1 = ’testx2xz’.
itab-n2 = ’testx3xz’.
MODIFY zdblnkt FROM itab.
***********************************************