IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Error while fetching the record from table


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mainframesiva

New User


Joined: 01 Jan 2020
Posts: 3
Location: India

PostPosted: Sun May 09, 2021 5:57 pm
Reply with quote

After reading the file and taking a field as input, i tried to fetch the value from the table. fetch cursor is returning 100 even when there are rows. verified the query through spufi and data is fetched correctly.
B_FSER -> Table field
B_TYP -> Table field
Table TABB(serial,type) with the data as below
A001-A
A001-B
A001-F
Code:
EXEC SQL DECLARE CUR1 CURSOR FOR             
    SELECT B_FSER,B_FTYP FROM TABB WHERE B_FSER = :WK-SER
END-EXEC
EXEC SQL
    FETCH CUR1 INTO :W-B-FSER,:W-B-FTYP
END-EXEC


attached the entire code...
can somebody help me out to identify the root cause..
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Sun May 09, 2021 9:11 pm
Reply with quote

You must:

1) carefully verify the content of your table using any online tool, such as FileAid DB2, or any other one available at your site. Do not rely on your guess - “It must be correct”

2) carefully trace your code, including exact values of all involved variables, by adding extra output (print) statements into your code

These are mandatory skills one needs to use when developing and debugging any code in any language. This is your own job you are paid for. Usually nobody else is going to do this draggy work instead of you.

Trying just to guess “what might be wrong in my excellent code” - is senseless activity in most real situations.
Back to top
View user's profile Send private message
mainframesiva

New User


Joined: 01 Jan 2020
Posts: 3
Location: India

PostPosted: Sun May 09, 2021 9:56 pm
Reply with quote

Issue has been resolved.
Moved the open cursor after the key value is moved to ensure the key is correctly passed.
Thanks all for your time...
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Tue May 11, 2021 12:48 am
Reply with quote

The very useful steps to resolve any problem:

1) try to think with your own mind

2) do something else
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Error when install DB2 DB2 2
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top