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

SQLCODE=100 and SQLSTAE 02000


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Fri Jan 19, 2018 10:14 am
Reply with quote

Hi all,
I have a strange issue as bellow.

Step 1: Unloading records from table TABLE1 using IKJEFT01 and writing to a file. These are KEY records.

Step2: Execute a cobol program to fetch full record from VSAM using the keys fetched from step 1.

Step3: When the fetch is successful, delete that key record from TABLE1. If record is not found, write to reject.

Issue: first 2 steps are working perfectly. But facing issue in 3rd step. Here the first record is getting deleted, but for subsequent DELETES, it is throwing sqlcode 100.

What could be the issue?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8794
Location: Welsh Wales

PostPosted: Fri Jan 19, 2018 1:21 pm
Reply with quote

What did Mr Google say when you asked him ?
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Fri Jan 19, 2018 1:57 pm
Reply with quote

No response from google for this behavior. icon_smile.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Senior Moderator


Joined: 14 Mar 2007
Posts: 10712
Location: italy

PostPosted: Fri Jan 19, 2018 2:07 pm
Reply with quote

Quote:
Step 1: Unloading records from table TABLE1 using IKJEFT01 and writing to a file. These are KEY records.


You might want to review Your understanding of the terminology

telling that You are using iIKJEFT01 is a useless information
IKJEFT01 is the TSO terminal monitor program which just reads from the SYSTSIN DD a sequence of commands to be executed
( could be any sequence of arbitrary commands as defined by the product/application invoked - not necessarily DB2 or QMF or ISPF )

If You want to provide useful information You should tell the name of the DB2 Utility used/ the command invoked
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2448
Location: Hampshire, UK

PostPosted: Fri Jan 19, 2018 3:37 pm
Reply with quote

Step 2 is, presumably, an in-house program. But what about steps 1 and 3? Are they in-house, DB2 utilities or some 3rd party utilities? Any old way - nothing is "throwing" anything because nothing is "thrown" on a mainframe.

Do you know what an SQLCODE of 100 means?
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Fri Jan 19, 2018 5:12 pm
Reply with quote

Step 1 is not DB2 utility, but just a select statement in SYSIN of IKJEFT1A as below

Code:

SELECT * FROM DELTA1             
         WHERE DB2_TIMESTMP <= CURRENT_TIMESTAMP
         WITH UR;                               


Step 3 is part of cobol program itself (of step2), where a successfully fetched record is being deleted as below.

Code:

EXEC SQL                                     
     DELETE FROM DELTA1               
     WHERE INST         = :WSC-INST         
       AND  CUST         = :WSC-CUST         
       AND  LDGR         = :WSC-LDGR         
       AND  ACCT         = :WSC-ACCT         
       AND  REC_TYP      = :WSC-REC-TYP     
       AND  NBR          = :WSC-NBR         
       AND  ACTION       = :WSC-ACTION       
       AND  DB2_TIMESTMP = :WSC-DB2-TIMESTAMP
END-EXEC.                                   


I can see that record is present in DELTA1, but I am getting SQLCODE 100(record not found). I displayed the values to see whether correct values are populated in host variables, that also looks fine.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2448
Location: Hampshire, UK

PostPosted: Fri Jan 19, 2018 7:12 pm
Reply with quote

Well, if you delete it then it will not be found subsequently unless you update the host variables. Are they being updated correctly?

As to the select statement in IKJEFT1A - I have no ide what that would do because, as Enrico pointed out, IKJEFT1A is TSO in batch and nothing more. What is your output from that? What is your JCL for that? Perhaps there is a prgram being run via the PARM to IKJEFT1A?
Back to top
View user's profile Send private message
enrico-sorichetti

Senior Moderator


Joined: 14 Mar 2007
Posts: 10712
Location: italy

PostPosted: Fri Jan 19, 2018 7:19 pm
Reply with quote

the TS did not get my hint about SYSTSIN icon_cool.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Fri Jan 19, 2018 8:29 pm
Reply with quote

I highly suspect you are incorrectly populating :WSC-DB2-TIMESTAMP .
Quote:
I can see that record is present in DELTA1, but I am getting SQLCODE 100(record not found). I displayed the values to see whether correct values are populated in host variables, that also looks fine.

Try to run sql by itself outside the program and see what happens.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1348
Location: Israel

PostPosted: Mon Jan 22, 2018 7:38 pm
Reply with quote

Instead of unloading a DB2 table and then reading the resulting sequential file, why don't you read the table directly from your cobol program:
1. Fetch one row
2. Use the key to read from VSAM file
3. If found, delete current row
4. If not found, write to reject
5. go to step 1
Declare the cursor WITH HOLD (so you can COMMIT from time to time) and FOR UPDATE.
Use DELETE WHERE CURRENT OF.
One step, one program, everything is under control.

pshongal wrote:
Step 1 is not DB2 utility, but just a select statement in SYSIN of IKJEFT1A
Best answer ever !!

Quote:
nothing is "throwing" anything because nothing is "thrown" on a mainframe.
Similarly, you do not fetch records from a VSAM file, you read them.
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Tue Jan 23, 2018 12:42 pm
Reply with quote

Quote:
Well, if you delete it then it will not be found subsequently unless you update the host variables. Are they being updated correctly?

Quote:
I highly suspect you are incorrectly populating :WSC-DB2-TIMESTAMP


Yes, TS is populated correctly. And other variables also are populated correctly. When I checked this outside the program, it works fine.

Quote:
Instead of unloading a DB2 table and then reading the resulting sequential file, why don't you read the table directly from your cobol program


Hi Marso, I had thought of this approach. My worry was whether this cause any outage? Because this is the trigger table and will have continuous inserts/Updates based on some online activity.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2448
Location: Hampshire, UK

PostPosted: Tue Jan 23, 2018 3:35 pm
Reply with quote

Quote:
When I checked this outside the program, it works fine.

How can you check that the variables are filled correctly outside of the program? Have you displayed them immediately before executing the sql statement? And I mean immediately before, not 5, 10 whatever lines of code before.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1348
Location: Israel

PostPosted: Tue Jan 23, 2018 8:49 pm
Reply with quote

Whether you use your cobol program to fetch and delete (as I suggested) or to only delete (as you plan to do), you face the same problem: you have a cobol program updating a "live" DB2 table.
You have to check the locking level for this table, find which isolation clause fits best (not sure UR is what you need), and get a recommendation for your commit rate.
If you can contact a DBA, discuss all this with him.

I think that doing many DELETE WHERE CURRENT will be much faster than doing many individual DELETEs.
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 -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts SQLCODE=-204 SQLSTATE=42704 DB2 4
No new posts Getting sqlcode 805 while executing R... DB2 10
No new posts SQLCODE -950 in PREPARE statement ... DB2 2
No new posts How to resolve sqlcode of CALL ATTACH... DB2 3
Search our Forums:

Back to Top