一条一条读取全部符合记录
DS
I 1 132 D#DATA
I 133 135 D#KEY
DS
I 1 4 W#BLK
I 5 7 W#KEY
I 8 20 W#DTA
I 21 132 W#SPC
**
C MOVEL'111' ##KEY 3
**
C/EXEC SQL
C+ DECLARE C1 CURSOR FOR
C+ SELECT SPLF,SUBSTR(SPLF,5,3) AS KEY
C+ FROM PTRLIB/SPLF
C+ WHERE SUBSTR(SPLF,5,3) = :##KEY
C+ ORDER BY KEY
C/END-EXEC
**
C/EXEC SQL
C+ OPEN C1
C/END-EXEC
**
C LABF TAG
C MOVEL*BLANK
C/EXEC SQL
C+ FETCH C1 INTO :D@DTA
C/END-EXEC
**
C SQLCOD IFEQ *ZERO
C MOVELD#DATA
C W#KEY DSPLY
C W#DTA DSPLY
C GOTO LABF
C ENDIF
**
C/EXEC SQL
C+ CLOSE C1
C/END-EXEC
**
C SETON LR
C RETRN
读取指定条数的符合记录
DS 10
I 1 132 D#DATA
I 133 135 D#KEY
DS
I 1 4 W#BLK
I 5 7 W#KEY
I 8 20 W#DTA
I 21 132 W#SPC
**
C MOVEL'111' ##KEY 3
**
C/EXEC SQL
C+ DECLARE C1 CURSOR FOR
C+ SELECT SPLF,SUBSTR(SPLF,5,3) AS KEY
C+ FROM PTRLIB/SPLF
C+ WHERE SUBSTR(SPLF,5,3) = :##KEY
C+ ORDER BY KEY
C/END-EXEC
**
C/EXEC SQL
C+ OPEN C1
C/END-EXEC
**
C LABF TAG
C/EXEC SQL
C+ FETCH C1 FOR 10 ROWS INTO :D@DTA
C/END-EXEC
**
C SQLCOD IFEQ *ZERO
C 1 DO 10 #I 20
C #I OCUR
C MOVELD#DATA
C W#KEY DSPLY
C W#DTA DSPLY
C MOVEL*BLANK
C ENDDO
C GOTO LABF
C ENDIF
**
C/EXEC SQL
C+ CLOSE C1
C/END-EXEC
**
C SETON LR
C RETRN
阅读(2228) | 评论(0) | 转发(1) |