Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
SQLCODE=100 and SQLSTAE 02000

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
pshongal

New User


Joined: 14 Jun 2012
Posts: 88
Location: India

PostPosted: Fri Jan 19, 2018 10:14 am    Post subject: SQLCODE=100 and SQLSTAE 02000
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: 8646
Location: Back in jolly old England

PostPosted: Fri Jan 19, 2018 1:21 pm    Post subject:
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: 88
Location: India

PostPosted: Fri Jan 19, 2018 1:57 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10413
Location: italy

PostPosted: Fri Jan 19, 2018 2:07 pm    Post subject: Reply to: SQLCODE=100 and SQLSTAE 02000
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: 1967
Location: UK

PostPosted: Fri Jan 19, 2018 3:37 pm    Post subject:
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: 88
Location: India

PostPosted: Fri Jan 19, 2018 5:12 pm    Post subject:
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: 1967
Location: UK

PostPosted: Fri Jan 19, 2018 7:12 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10413
Location: italy

PostPosted: Fri Jan 19, 2018 7:19 pm    Post subject: Reply to: SQLCODE=100 and SQLSTAE 02000
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

Senior Member


Joined: 21 Sep 2010
Posts: 1842
Location: NY,USA

PostPosted: Fri Jan 19, 2018 8:29 pm    Post subject:
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: 1268
Location: Israel

PostPosted: Mon Jan 22, 2018 7:38 pm    Post subject:
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: 88
Location: India

PostPosted: Tue Jan 23, 2018 12:42 pm    Post subject:
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: 1967
Location: UK

PostPosted: Tue Jan 23, 2018 3:35 pm    Post subject:
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: 1268
Location: Israel

PostPosted: Tue Jan 23, 2018 8:49 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQLCODE 518 while executing DB2 module. abdulrafi DB2 8 Wed Feb 07, 2018 10:46 am
No new posts DB2 SQL Error: SQLCODE=-440, SQLSTATE... kishpra DB2 1 Sat Feb 18, 2017 2:31 am
No new posts SQLCODE-000000080N priya91 DB2 1 Mon Feb 01, 2016 4:35 pm
No new posts Need to understand SQLCODE = 12 rohanthengal DB2 3 Thu Nov 05, 2015 11:22 am
No new posts SQLCODE -922 in Batch-Cics program tr... kishpra CICS 2 Thu Sep 10, 2015 12:36 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us