thelearner
Programmer
Hi,
I have very simple SQL embeded pgm, just read/print for record that has date >= specified date. The file has almost 800,000 records. The pgm took almost 1 min. to run. I used the same SELECT statement and run in STRSQL. It took only 2-3 sec. What's wrong with my program? Can any one help?
Thanks.
FQSYSPRT O F 132 PRINTER OFLIND(*INOF)
D MAIN PR EXTPGM('VS040')
D 5
D 1
D MAIN PI
D ZPENT 5
D ZRPTYP 1
*
D TKREC E DS EXTNAME(TKMAST)
D CISPFX S 6
D PHEADR S 20
*-----------------------------------------------
* M A I N
*-----------------------------------------------
C/EXEC SQL
C+ SET OPTION
C+ COMMIT = *NONE,
C+ CLOSQLCSR = *ENDMOD
C/END-EXEC
C/EXEC SQL
C+ DECLARE MYCURSOR SCROLL CURSOR FOR
C+ SELECT *
C+ FROM TKMAST
C+ WHERE TKOPNC * 1000000 + TKOPNY * 10000 + TKOPNM * 100 +
C+ TKOPND >= 20040308 AND
C+ TKPENT = '2704 ' AND TKETCD <> '00'
C+ FOR FETCH ONLY
C/END-EXEC
C/EXEC SQL
C+ OPEN MYCURSOR
C/END-EXEC
/FREE
DOW SQLCOD = 0;
/END-FREE
C/EXEC SQL
C+ FETCH FROM MYCURSOR
C+ INTO :TKREC
C/END-EXEC
/FREE
IF SQLCOD = 100; // end-of-data
LEAVE;
ENDIF;
CISPFX = TKBRCD + TKDVCD + %EDITC(TKFLYY:'X');
EXCEPT #DETL;
ENDDO;
EXCEPT #EOF;
*INLR = '1';
//-------------------
/END-FREE
I have very simple SQL embeded pgm, just read/print for record that has date >= specified date. The file has almost 800,000 records. The pgm took almost 1 min. to run. I used the same SELECT statement and run in STRSQL. It took only 2-3 sec. What's wrong with my program? Can any one help?
Thanks.
FQSYSPRT O F 132 PRINTER OFLIND(*INOF)
D MAIN PR EXTPGM('VS040')
D 5
D 1
D MAIN PI
D ZPENT 5
D ZRPTYP 1
*
D TKREC E DS EXTNAME(TKMAST)
D CISPFX S 6
D PHEADR S 20
*-----------------------------------------------
* M A I N
*-----------------------------------------------
C/EXEC SQL
C+ SET OPTION
C+ COMMIT = *NONE,
C+ CLOSQLCSR = *ENDMOD
C/END-EXEC
C/EXEC SQL
C+ DECLARE MYCURSOR SCROLL CURSOR FOR
C+ SELECT *
C+ FROM TKMAST
C+ WHERE TKOPNC * 1000000 + TKOPNY * 10000 + TKOPNM * 100 +
C+ TKOPND >= 20040308 AND
C+ TKPENT = '2704 ' AND TKETCD <> '00'
C+ FOR FETCH ONLY
C/END-EXEC
C/EXEC SQL
C+ OPEN MYCURSOR
C/END-EXEC
/FREE
DOW SQLCOD = 0;
/END-FREE
C/EXEC SQL
C+ FETCH FROM MYCURSOR
C+ INTO :TKREC
C/END-EXEC
/FREE
IF SQLCOD = 100; // end-of-data
LEAVE;
ENDIF;
CISPFX = TKBRCD + TKDVCD + %EDITC(TKFLYY:'X');
EXCEPT #DETL;
ENDDO;
EXCEPT #EOF;
*INLR = '1';
//-------------------
/END-FREE