DBLINK设定的数据
1. 用TCode: DBCO设定数据联接
Oracle连接配置如下
2. 程序示例
REPORT ytest.
CONSTANTS: con(20) TYPE c VALUE 'PFSTEST'.
CONSTANTS: con(20) TYPE c VALUE 'PFSTEST'.
DATA: lv_str TYPE string,
lr_ex TYPE REF TO cx_root.
DATA: BEGIN OF lt OCCURS 0,
uuid(10),
pt_type(4),
balance TYPE p DECIMALS 2,
END OF lt.
DATA: "lt TYPE TABLE OF zcms2001,
ls LIKE LINE OF lt.
EXEC SQL .
CONNECT TO :con
ENDEXEC.
IF sy-subrc <> 0.
MESSAGE '连接失败' TYPE 'E'.
EXIT.
ENDIF.
EXEC SQL.
SET CONNECTION :con
ENDEXEC.
TRY.
EXEC SQL.
OPEN dbcur FOR
SELECT UUID, PT_TYPE, BALANCE FROM YTEST
ENDEXEC.
DO.
EXIT.
ENDIF.
EXEC SQL.
SET CONNECTION :con
ENDEXEC.
TRY.
EXEC SQL.
OPEN dbcur FOR
SELECT UUID, PT_TYPE, BALANCE FROM YTEST
ENDEXEC.
DO.
EXEC SQL.
FETCH NEXT dbcur into structure :ls package size 1000
ENDEXEC.
IF sy-subrc IS INITIAL.
APPEND ls TO lt.
ELSE.
EXIT.
ENDIF.
ENDDO.
EXEC SQL.
CLOSE dbcur
ENDEXEC.
CATCH cx_root INTO lr_ex.
FETCH NEXT dbcur into structure :ls package size 1000
ENDEXEC.
IF sy-subrc IS INITIAL.
APPEND ls TO lt.
ELSE.
EXIT.
ENDIF.
ENDDO.
EXEC SQL.
CLOSE dbcur
ENDEXEC.
CATCH cx_root INTO lr_ex.
ENDTRY.
EXEC SQL.
SET CONNECTION 'DEFAULT'
ENDEXEC.
EXEC SQL.
DISCONNECT :con
ENDEXEC.
EXEC SQL.
SET CONNECTION 'DEFAULT'
ENDEXEC.
EXEC SQL.
DISCONNECT :con
ENDEXEC.
转载另一个更新程序:
CONSTANTS: con(20) TYPE c VALUE ' CONSTRING'.
EXEC SQL.
SET CONNECTION :con
ENDEXEC.
IF sy-subrc <> 0.
EXEC SQL .
CONNECT TO :con
ENDEXEC.
IF sy-subrc <> 0.
MESSAGE '连接失败' TYPE 'E'.
EXIT.
ENDIF.
ENDIF.
EXEC SQL.
DELETE FROM DB2INST1.EXAMPLEDATA
where FinComCode = :lc_bukrs
and FinDate = :lc_spmon
ENDEXEC.
ENDLOOP.
CALL FUNCTION 'DB_COMMIT'.
EXEC SQL.
INSERT INTO DB2INST1.LFFINBASE
( FinComCode,ItemCode,ReportDate,StatValue,MakeDate,MakeTime,FinDate )
VALUES ( :lc_bukrs,:lc_zhbbm,:lc_budat,:itab_021-dmbtr,:lc_datum,:lc_uzeit,:lc_spmon )
ENDEXEC.
ENDLOOP.
CALL FUNCTION 'DB_COMMIT'.
oracle decimal类型
EXEC SQL.
SET CONNECTION 'DEFAULT'
ENDEXEC.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论