我正在尝试使用 OpenCOBOL IDE 和 DB2 Express-C。一个非常简单的程序 TEST0002.sqb 已准备好并与 DB2 创建绑定 - TEST0002.bnd 和 TEST0002.cbl 文件。现在,当我在 OpenCOBOL IDE 中执行程序时,我得到 -805。显示以下消息:(另附)
F:\COBOL\bin\TEST0002.exe
CONNECT :)+000000000+1ÿ1208ÿAKADIAN
ÿSAMPLEÿQDB2/NT64ÿ2268ÿ2268ÿ0ÿ1252ÿ0ÿ
SQLCODE: -000000805
SQLCAID: SQLCA
SQLCABC: +000000136
SQLERRML: +0036
SQLERRMC: A Øõ( . CÀ[¸õ( 0X00000000604B4100
SQLERRP: SQLRA14D
SQLSTATE: 51002
SQLWARN:
Hello world: 0 -->THIS SHOULD BE 1 IF SQL WORKED :)
--- error report ---
ERROR occurred :
SQLCODE : -000000805
ERR BUFFER :
ERR BUFFER : SQL0805N Package " A Øõ( . CÀ[¸õ( 0X00000000604B4100"
was not found.
SQLSTATE=51002
Package: A Øõ( . CÀ[¸õ( 0X00000000604B4100
001SQL0805N Package " A Øõ( . CÀ[¸õ( 0X00000000604B4100" was not
found.
SQLSTATE=51002
SQLSTATE 51002: The package corresponding to an SQL statement
execution request
was not found.
--- end error report ---****
Process finished with exit code 98
TEST0002.sqb
IDENTIFICATION DIVISION.
PROGRAM-ID. TEST0002.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
*-----------------------
INPUT-OUTPUT SECTION.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
COPY 'sql.cbl'.
COPY 'sqlenv.cbl'.
EXEC SQL
BEGIN DECLARE SECTION
END-EXEC.
01 WS-SQL-FETCH pic X(01) value '0'.
EXEC SQL
END DECLARE SECTION
END-EXEC.
77 errloc pic x(80).
EXEC SQL
INCLUDE SQLCA
END-EXEC.
PROCEDURE DIVISION.
MAIN-PROCEDURE.
EXEC SQL
CONNECT TO SAMPLE
END-EXEC.
if SQLCODE not equal zero
then
display 'CONNECT failed with rc ' SQLCODE '+' SQLERRMC
else display 'CONNECT :)' SQLCODE '+' SQLERRMC
end-if.
EXEC SQL
SELECT '1'
INTO :WS-SQL-FETCH
FROM EMPLOYEE
FETCH FIRST 1 ROW ONLY
END-EXEC.
if SQLCODE not equal zero
then
DISPLAY 'SQLCODE: ' SQLCODE
DISPLAY 'SQLCAID: ' SQLCAID
DISPLAY 'SQLCABC: ' SQLCABC
DISPLAY 'SQLERRML: ' SQLERRML
DISPLAY 'SQLERRMC: ' SQLERRMC
DISPLAY 'SQLERRP: ' SQLERRP
DISPLAY 'SQLSTATE: ' SQLSTATE
DISPLAY 'SQLWARN: ' SQLWARN
DISPLAY "Hello world: " WS-SQL-FETCH
" -->THIS SHOULD BE 1 IF SQL WORKED :) "
call 'checkerr' using SQLCA, errloc
end-if.
STOP RUN.
END PROGRAM TEST0002.
准备、装订和包装信息:
db2 => prep F:\COBOL\sqb\TEST0002.sqb target ANSI_COBOL BINDFILE USING F:\COBOL\
bnd\TEST0002.bnd QUALIFIER AKADIAN COLLECTION AKADIAN OUTPUT F:\COBOL\cbl\TEST00
02.cbl VALIDATE BIND
LINE MESSAGES FOR TEST0002.sqb
------ --------------------------------------------------------------------
SQL0060W The "COBOL" precompiler is in progress.
SQL0091W Precompilation or binding was ended with "0"
errors and "0" warnings.
db2 => bind F:\COBOL\bnd\TEST0002.bnd OWNER AKADIAN QUALIFIER AKADIAN COLLECTION
AKADIAN EXPLAIN NO VALIDATE BIND
LINE MESSAGES FOR TEST0002.bnd
------ ---------------------------------------------- -----------------
-----
SQL0061W The binder is in progress.
SQL0091N Binding was ended with "0" errors and "0" warnings.
db2 => quit
DB20000I The QUIT command completed successfully.
C:\Windows\system32>db2bfd -b F:\COBOL\bnd\TEST0002.bnd
F:\COBOL\bnd\TEST0002.bnd: Header Contents
Header Fields:
Field Value
----- -----
releaseNum 0x800
Endian 0x4c
numHvars 1
maxSect 1
numStmt 5
optInternalCnt 5
optCount 11
Name Value
------------------ -----
Isolation Level Cursor Stability
Creator "AKADIAN "
Collection "AKADIAN "
App Name "TEST0002"
Timestamp "KAHjVNEg:2016/04/13 21:35:07:10"
Cnulreqd Yes
Sql Error No package
Qualifier "AKADIAN"
Validate Bind
Date Default/local
Time Default/local
预编译后的COBOL源: TEST0002.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. TEST0002.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 SQLDA-ID pic 9(4) comp-5.
01 SQLDSIZE pic 9(4) comp-5.
01 SQL-STMT-ID pic 9(4) comp-5.
01 SQLVAR-INDEX pic 9(4) comp-5.
01 SQL-DATA-TYPE pic 9(4) comp-5.
01 SQL-HOST-VAR-LENGTH pic 9(9) comp-5.
01 SQL-S-HOST-VAR-LENGTH pic 9(9) comp-5.
01 SQL-S-LITERAL pic X(258).
01 SQL-LITERAL1 pic X(130).
01 SQL-LITERAL2 pic X(130).
01 SQL-LITERAL3 pic X(130).
01 SQL-LITERAL4 pic X(130).
01 SQL-LITERAL5 pic X(130).
01 SQL-LITERAL6 pic X(130).
01 SQL-LITERAL7 pic X(130).
01 SQL-LITERAL8 pic X(130).
01 SQL-LITERAL9 pic X(130).
01 SQL-LITERAL10 pic X(130).
01 SQL-IS-LITERAL pic 9(4) comp-5 value 1.
01 SQL-IS-INPUT-HVAR pic 9(4) comp-5 value 2.
01 SQL-CALL-TYPE pic 9(4) comp-5.
01 SQL-SECTIONUMBER pic 9(4) comp-5.
01 SQL-INPUT-SQLDA-ID pic 9(4) comp-5.
01 SQL-OUTPUT-SQLDA-ID pic 9(4) comp-5.
01 SQLA-PROGRAM-ID.
05 SQL-PART1 pic 9(4) COMP-5 value 172.
05 SQL-PART2 pic X(6) value "AEAQAI".
05 SQL-PART3 pic X(24) value "KAHjVNEg01111 2 ".
05 SQL-PART4 pic 9(4) COMP-5 value 8.
05 SQL-PART5 pic X(8) value "AKADIAN ".
05 SQL-PART6 pic X(120) value LOW-VALUES.
05 SQL-PART7 pic 9(4) COMP-5 value 8.
05 SQL-PART8 pic X(8) value "TEST0002".
05 SQL-PART9 pic X(120) value LOW-VALUES.
COPY 'sql.cbl'.
COPY 'sqlenv.cbl'.
01 WS-SQL-FETCH pic X(01) value '0'.
77 errloc pic x(80).
COPY 'sqlca.cbl'.
PROCEDURE DIVISION.
MAIN-PROCEDURE.
CALL "sqlgstrt" USING
BY CONTENT SQLA-PROGRAM-ID
BY VALUE 0
BY REFERENCE SQLCA
MOVE 1 TO SQL-STMT-ID
MOVE 1 TO SQLDSIZE
MOVE 2 TO SQLDA-ID
CALL "sqlgaloc" USING
BY VALUE SQLDA-ID
SQLDSIZE
SQL-STMT-ID
0
MOVE "SAMPLE"
TO SQL-LITERAL1
MOVE 6 TO SQL-HOST-VAR-LENGTH
MOVE 452 TO SQL-DATA-TYPE
MOVE 0 TO SQLVAR-INDEX
MOVE 2 TO SQLDA-ID
CALL "sqlgstlv" USING
BY VALUE SQLDA-ID
SQLVAR-INDEX
SQL-DATA-TYPE
SQL-HOST-VAR-LENGTH
BY REFERENCE SQL-LITERAL1
BY VALUE 0
0
MOVE 0 TO SQL-OUTPUT-SQLDA-ID
MOVE 2 TO SQL-INPUT-SQLDA-ID
MOVE 4 TO SQL-SECTIONUMBER
MOVE 29 TO SQL-CALL-TYPE
CALL "sqlgcall" USING
BY VALUE SQL-CALL-TYPE
SQL-SECTIONUMBER
SQL-INPUT-SQLDA-ID
SQL-OUTPUT-SQLDA-ID
0
CALL "sqlgstop" USING
BY VALUE 0
.
if SQLCODE not equal zero
then
display 'CONNECT failed with rc ' SQLCODE '+' SQLERRMC
else display 'CONNECT :)' SQLCODE '+' SQLERRMC
end-if.
CALL "sqlgstrt" USING
BY CONTENT SQLA-PROGRAM-ID
BY VALUE 0
BY REFERENCE SQLCA
MOVE 2 TO SQL-STMT-ID
MOVE 1 TO SQLDSIZE
MOVE 3 TO SQLDA-ID
CALL "sqlgaloc" USING
BY VALUE SQLDA-ID
SQLDSIZE
SQL-STMT-ID
0
MOVE 1 TO SQL-HOST-VAR-LENGTH
MOVE 452 TO SQL-DATA-TYPE
MOVE 0 TO SQLVAR-INDEX
MOVE 3 TO SQLDA-ID
CALL "sqlgstlv" USING
BY VALUE SQLDA-ID
SQLVAR-INDEX
SQL-DATA-TYPE
SQL-HOST-VAR-LENGTH
BY REFERENCE WS-SQL-FETCH
BY VALUE 0
0
MOVE 3 TO SQL-OUTPUT-SQLDA-ID
MOVE 0 TO SQL-INPUT-SQLDA-ID
MOVE 1 TO SQL-SECTIONUMBER
MOVE 24 TO SQL-CALL-TYPE
CALL "sqlgcall" USING
BY VALUE SQL-CALL-TYPE
SQL-SECTIONUMBER
SQL-INPUT-SQLDA-ID
SQL-OUTPUT-SQLDA-ID
0
CALL "sqlgstop" USING
BY VALUE 0
.
if SQLCODE not equal zero
then
DISPLAY 'SQLCODE: ' SQLCODE
DISPLAY 'SQLCAID: ' SQLCAID
DISPLAY 'SQLCABC: ' SQLCABC
DISPLAY 'SQLERRML: ' SQLERRML
DISPLAY 'SQLERRMC: ' SQLERRMC
DISPLAY 'SQLERRP: ' SQLERRP
DISPLAY 'SQLSTATE: ' SQLSTATE
DISPLAY 'SQLWARN: ' SQLWARN
DISPLAY "Hello world: " WS-SQL-FETCH
" -->THIS SHOULD BE 1 IF SQL WORKED :) "
call 'checkerr' using SQLCA, errloc
end-if.
STOP RUN.
END PROGRAM TEST0002.