THIS IS MY PROGRAM
IDENTIFICATION DIVISION.
PROGRAM-ID. SCROL.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OUTFILE ASSIGN TO DD2.
DATA DIVISION.
FILE SECTION.
FD OUTFILE.
01 OUTRECORD.
05 ACCNO PIC 9(4).
05 ACCNAME PIC X(20).
05 FILLER PIC X(56).
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE TB1
END-EXEC.
EXEC SQL
DECLARE CUR1 SENSITIVE STATIC SCROLL CURSOR FOR
SELECT ACCNO, ACCNAME
FROM TB1
END-EXEC.
PROCEDURE DIVISION.
OPEN OUTPUT OUTFILE.
EXEC SQL
OPEN CUR1
END-EXEC.
EXEC SQL
FETCH CUR1 INTO :HACCNO, :HACCNAME
END-EXEC.
EXEC SQL
FETCH RELATIVE +2 FROM CUR1 INTO :HACCNO, :HACCNAME
END-EXEC.
MOVE HACCNO TO ACCNO.
MOVE HACCNAME TO ACCNAME.
WRITE OUTRECORD.
CLOSE OUTFILE.
EXEC SQL
CLOSE CUR1
END-EXEC.
IF SQLCODE = 00
DISPLAY 'SUCCESSFULLY WRITED TO FILE', SQLCODE
ELSE
DISPLAY 'FAILED AT WRITING', SQLCODE
DISPLAY 'ACCNO', ACCNO
DISPLAY 'ACCNAME', ACCNAME
END-IF.
STOP RUN.
AND MY TABLE IS
ACCNO ACCNAME
------ --------------------
1234 BILL CLINTON
2000 BARACK
3000 HILLARY
4000 GEORGE
Here my primary key is ACCNO
and writing out put to a file
i am getting 50J sql code.
what is the problem with my program.
am i doing right or any wrong in program.plz clarify.
with regards.