当前位置: 技术问答>linux和unix
Pro*Cobol乱码请教
来源: 互联网 发布时间:2015-12-24
本文导语: ****************************************************************** IDENTIFICATION DIVISION. ****************************************************************** PROGRAM-ID. ...
******************************************************************
IDENTIFICATION DIVISION.
******************************************************************
PROGRAM-ID. t.
******************************************************************
ENVIRONMENT DIVISION.
******************************************************************
******************************************************************
DATA DIVISION.
******************************************************************
******************************************************************
FILE SECTION.
******************************************************************
******************************************************************
WORKING-STORAGE SECTION.
******************************************************************
EXEC SQL INCLUDE SQLCA END-EXEC.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 USERNAME PIC X(40) VARYING.
01 PASSWD PIC X(40) VARYING.
COPY "fconnwk.cpy".
01 W-TOUGETU PIC X(06).
01 XXXXX PIC x(100) USAGE IS NCHAR.
EXEC SQL END DECLARE SECTION END-EXEC.
******************************************************************
PROCEDURE DIVISION.
******************************************************************
START-RTN SECTION.
*------------------*
PERFORM INIT-RTN.
*------------------*
PERFORM MAIN-RTN.
*------------------*
PERFORM END-RTN.
******************************************************************
*(1.0) init
******************************************************************
INIT-RTN SECTION.
EXEC SQL WHENEVER SQLERROR
DO PERFORM SQL-ERROR-RTN
END-EXEC.
PERFORM LOGON.
INIT-RTN-EX.
EXIT.
******************************************************************
*(1.1) db login
******************************************************************
LOGON SECTION.
DISPLAY "S_USER" UPON ENVIRONMENT-NAME.
ACCEPT USER-NM FROM ENVIRONMENT-VALUE.
DISPLAY "S_PASS" UPON ENVIRONMENT-NAME.
ACCEPT PASS-NM FROM ENVIRONMENT-VALUE.
COPY "fconnst.cpy".
EXEC SQL CONNECT :USERNAME IDENTIFIED BY :PASSWD END-EXEC.
COPY "fconnck.cpy".
LOGON-EX.
EXIT.
******************************************************************
*(2.0) main
******************************************************************
MAIN-RTN SECTION.
EXEC SQL
SELECT
*
into :W-TOUGETU
FROM
dsas
END-EXEC.
MAIN-RTN-EX.
EXIT.
******************************************************************
*(3.0) end
******************************************************************
END-RTN SECTION.
EXEC SQL ROLLBACK WORK RELEASE END-EXEC.
STOP RUN RETURNING 0.
END-RTN-EX.
EXIT.
******************************************************************
*(4.0)err
******************************************************************
SQL-ERROR-RTN SECTION.
EXEC SQL WHENEVER SQLERROR CONTINUE END-EXEC.
DISPLAY 't SQL-ERROR'.
DISPLAY 'Message :' SQLERRMC.
MOVE SQLERRMC to XXXXX.
DISPLAY 'Message :' XXXXX.
EXEC SQL ROLLBACK WORK RELEASE END-EXEC.
STOP RUN RETURNING 1.
-----------------------------------------------------------------------------
出现错误时显示Oracle消息:SQLERRMC
乱码。
运行环境默认 EUC 编码,返回的消息串是 SHIFT-JIS 编码。
能转换成 EUC 吗?
IDENTIFICATION DIVISION.
******************************************************************
PROGRAM-ID. t.
******************************************************************
ENVIRONMENT DIVISION.
******************************************************************
******************************************************************
DATA DIVISION.
******************************************************************
******************************************************************
FILE SECTION.
******************************************************************
******************************************************************
WORKING-STORAGE SECTION.
******************************************************************
EXEC SQL INCLUDE SQLCA END-EXEC.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 USERNAME PIC X(40) VARYING.
01 PASSWD PIC X(40) VARYING.
COPY "fconnwk.cpy".
01 W-TOUGETU PIC X(06).
01 XXXXX PIC x(100) USAGE IS NCHAR.
EXEC SQL END DECLARE SECTION END-EXEC.
******************************************************************
PROCEDURE DIVISION.
******************************************************************
START-RTN SECTION.
*------------------*
PERFORM INIT-RTN.
*------------------*
PERFORM MAIN-RTN.
*------------------*
PERFORM END-RTN.
******************************************************************
*(1.0) init
******************************************************************
INIT-RTN SECTION.
EXEC SQL WHENEVER SQLERROR
DO PERFORM SQL-ERROR-RTN
END-EXEC.
PERFORM LOGON.
INIT-RTN-EX.
EXIT.
******************************************************************
*(1.1) db login
******************************************************************
LOGON SECTION.
DISPLAY "S_USER" UPON ENVIRONMENT-NAME.
ACCEPT USER-NM FROM ENVIRONMENT-VALUE.
DISPLAY "S_PASS" UPON ENVIRONMENT-NAME.
ACCEPT PASS-NM FROM ENVIRONMENT-VALUE.
COPY "fconnst.cpy".
EXEC SQL CONNECT :USERNAME IDENTIFIED BY :PASSWD END-EXEC.
COPY "fconnck.cpy".
LOGON-EX.
EXIT.
******************************************************************
*(2.0) main
******************************************************************
MAIN-RTN SECTION.
EXEC SQL
SELECT
*
into :W-TOUGETU
FROM
dsas
END-EXEC.
MAIN-RTN-EX.
EXIT.
******************************************************************
*(3.0) end
******************************************************************
END-RTN SECTION.
EXEC SQL ROLLBACK WORK RELEASE END-EXEC.
STOP RUN RETURNING 0.
END-RTN-EX.
EXIT.
******************************************************************
*(4.0)err
******************************************************************
SQL-ERROR-RTN SECTION.
EXEC SQL WHENEVER SQLERROR CONTINUE END-EXEC.
DISPLAY 't SQL-ERROR'.
DISPLAY 'Message :' SQLERRMC.
MOVE SQLERRMC to XXXXX.
DISPLAY 'Message :' XXXXX.
EXEC SQL ROLLBACK WORK RELEASE END-EXEC.
STOP RUN RETURNING 1.
-----------------------------------------------------------------------------
出现错误时显示Oracle消息:SQLERRMC
乱码。
运行环境默认 EUC 编码,返回的消息串是 SHIFT-JIS 编码。
能转换成 EUC 吗?
|
友情 up
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。