cobol!ibm大型机关于数据库与文件的操作
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
DENTIFICATION DIVISION.
PROGRAM-ID. SQLFILE.
AUTHOR. SD.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-PUT ASSIGN TO RECORD2.
DATA DIVISION.
FILE SECTION.
FD IN-PUT.
01 IN-REC.
03 MATCLE PIC X(6).
03 NAME PIC X(5).
03 DEPT PIC X(5).
03 SALARY PIC X(6).
WORKING-STORAGE SECTION.
EXEC SQL INCLUDE SQLCA END-EXEC.
PROCEDURE DIVISION.
READ-IN.
OPEN INPUT IN-PUT.
READ IN-PUT
NOT AT END
PERFORM SQL-IN.
AT END
DISPLAY 'FILE IS END'.
GO TO PRO-END.
SQL-IN.
EXEC SQL
INSERT INTO ZY01 VALUES ( :MATCLE, :NAME, :DEPT, :SALARY)
END-EXEC.
PRO-END.
IDENTIFICATION DIVISION.
PROGRAM-ID. SQLFILE.
AUTHOR. SD.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OUT-PUT ASSIGN TO OUT2.
DATA DIVISION.
FILE SECTION.
FD OUT-PUT.
FD OUT-PUT.
01 OUT-REC.
03 OMATCLE PIC X(6).
03 ONAME PIC X(5).
03 ODEPT PIC X(5).
03 OSALARY PIC X(6).
WORKING-STORAGE SECTION.
77 ODEP PIC X(5).
EXEC SQL INCLUDE ZY01 END-EXEC.
EXEC SQL INCLUDE SQLCA END-EXEC.
PROCEDURE DIVISION.
READ-IN.
OPEN OUTPUT OUT-PUT.
MOVE 'DEPT2' TO ODEP.
EXEC SQL
SELECT MATCLE, NAME, DEPT, SALARY INTO
:OMATCLE, :ONAME, :ODEPT, :OSALARY
AT FROM CK0002.ZY01 WHERE DEPT = :ODEP
EXEC-EN
D.
WRITE OUT-REC.
CLOSE OUT-PUT.