View previous topic :: View next topic
|
Author |
Message |
chaoj
Active User
Joined: 03 Jun 2010 Posts: 103 Location: Dalian
|
|
|
|
Hello all
I wrote a REXX pgm to select DB2 table and make the records to a particular format , but for some tables , I can not fetch all rows cause the SQLCODE returns 100 and no more rows was fetched . Please help .
I use SQLCODE = 100 to judge the end of the table record .
but for some table , there's 600 records in the table , when fetch 245 records , the SQLCODE was 100 .
(some table is OK , some table is NG)
Code: |
PARMSQL3 = "SELECT "TEMPCOL" FROM PK80U1."TBLNAME
"EXECSQL DECLARE C3 CURSOR FOR S3"
"EXECSQL PREPARE S3 FROM :PARMSQL3"
"EXECSQL OPEN C3"
DO FOREVER
"EXECSQL FETCH C3 INTO :DBDATA1"
IF SQLCODE = 100 THEN LEAVE
OUTLINE1.1 = DBDATA1
ADDRESS TSO "EXECIO 1 DISKW OUTDD1 (STEM OUTLINE1. "
END
"EXECSQL CLOSE C3"
|
|
|
Back to top |
|
|
chaoj
Active User
Joined: 03 Jun 2010 Posts: 103 Location: Dalian
|
|
|
|
by the way , I printed the SQLERRD.1,SQLERRD.2 and SQLERRD.3
but for all tables (OK or NG) , the SQLERRD was the same
SQLERRD.1:-110
SQLERRD.2:0
SQLERRD.3:0 |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Try something like this
Code: |
J=1
DO UNTIL (SQLCODE ¬= 0)
ADDRESS DSNREXX "EXECSQL FETCH C3 INTO :DBDATA1"
IF SQLCODE = 0 THEN DO
OUTLINE1.J = DBDATA1
END
END |
|
|
Back to top |
|
|
chaoj
Active User
Joined: 03 Jun 2010 Posts: 103 Location: Dalian
|
|
|
|
Pandora-Box wrote: |
Try something like this
Code: |
J=1
DO UNTIL (SQLCODE ¬= 0)
ADDRESS DSNREXX "EXECSQL FETCH C3 INTO :DBDATA1"
IF SQLCODE = 0 THEN DO
OUTLINE1.J = DBDATA1
END
END |
|
Thanks Pandora , I tried the code , but the remainder records in the table still could not fetch cause the SQLCODE=100 |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
The code works perfect for me and it is tested
I would suggest you to double check on table data |
|
Back to top |
|
|
chaoj
Active User
Joined: 03 Jun 2010 Posts: 103 Location: Dalian
|
|
|
|
Pandora-Box wrote: |
The code works perfect for me and it is tested
I would suggest you to double check on table data |
Thanks , some table is OK , and some table is not ,
maybe as you say , I should check the table , I wonder if there's problem with the index ?? |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Opps I did a mistake in copy paste
Code: |
J=1
DO UNTIL (SQLCODE ¬= 0)
ADDRESS DSNREXX "EXECSQL FETCH C3 INTO :DBDATA1"
IF SQLCODE = 0 THEN DO
OUTLINE1.J = DBDATA1
J=J+1
END
END |
After populating all to OUTLINE.J try to write that into output |
|
Back to top |
|
|
chaoj
Active User
Joined: 03 Jun 2010 Posts: 103 Location: Dalian
|
|
|
|
Pandora-Box wrote: |
Opps I did a mistake in copy paste
Code: |
J=1
DO UNTIL (SQLCODE ¬= 0)
ADDRESS DSNREXX "EXECSQL FETCH C3 INTO :DBDATA1"
IF SQLCODE = 0 THEN DO
OUTLINE1.J = DBDATA1
J=J+1
END
END |
After populating all to OUTLINE.J try to write that into output |
The result was the same , when fetch 245 records , sqlcode was set to 100
, then loop ended , the remainder 355 records could not be fetched ..... |
|
Back to top |
|
|
chaoj
Active User
Joined: 03 Jun 2010 Posts: 103 Location: Dalian
|
|
|
|
I run the REXX at the development environment and test environment , it OK ....... but at production environment , there's problem , any DB2 setup will affect the fetch ?? |
|
Back to top |
|
|
chaoj
Active User
Joined: 03 Jun 2010 Posts: 103 Location: Dalian
|
|
|
|
I found the reason .....
the remainder 355 records is rubbish data , and no key with the mother table , it's OK , sorry for your time Pandora |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Glad to know you figured out ..
But there is nothing as such rubbish data may be we didnt think that frist place |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
chaoj wrote: |
the remainder 355 records is rubbish data , and no key with the mother table , it's OK , sorry for your time Pandora |
There is(are) parent/child relations I heard of - -since when "mother table(s)" are being talked about... |
|
Back to top |
|
|
|