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
 
How to force a select query to abend

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

New User


Joined: 03 Oct 2016
Posts: 3
Location: India

PostPosted: Mon Apr 23, 2018 1:36 pm    Post subject: How to force a select query to abend
Reply with quote

Hi,

Is there any way to abend a select SQL inside a program to abend; without modifying the query? I need to abend the program to test a scenario, where any Sqlcode other than 0,+100 I have to insert a record in a different table. I can test this by manually moving a different sqlcode to the SQLCA variable; but want to know if there any any way without modified the program/sql.

I tried to force -811 but the primary key would not allow me to do so.

Let me know your suggestions.

Thanks,
Back to top
View user's profile Send private message

prino

Senior Member


Joined: 07 Feb 2009
Posts: 1117
Location: Oostende, Belgium

PostPosted: Mon Apr 23, 2018 7:16 pm    Post subject:
Reply with quote

Running the program under Debug Tool in batch will allow you to do this.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Mon Apr 23, 2018 7:40 pm    Post subject:
Reply with quote

I can test this by manually moving a different sqlcode to the SQLCA variable; but want to know if there any any way without modified the program/sql. How would that change the results of what you are testing?
Quote:

I tried to force -811 but the primary key would not allow me to do so.
If duplicates are not allowed then whats the point of testing -811, since it will never ever come? if you are joining with some other tables then you need to modify them ( if you can) to test the real scenario.
Back to top
View user's profile Send private message
neo4u

New User


Joined: 03 Oct 2016
Posts: 3
Location: India

PostPosted: Tue Apr 24, 2018 11:28 am    Post subject:
Reply with quote

Rohit Umarjikar wrote:
I can test this by manually moving a different sqlcode to the SQLCA variable; but want to know if there any any way without modified the program/sql. How would that change the results of what you are testing?
Quote:

I tried to force -811 but the primary key would not allow me to do so.
If duplicates are not allowed then whats the point of testing -811, since it will never ever come? if you are joining with some other tables then you need to modify them ( if you can) to test the real scenario.


What I am trying to test is not the SQLCODE, it is the step if I ever get an error other than 0 or +100. So by moving a false sqlcode, i can test the WHEN OTHER condition.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Tue Apr 24, 2018 1:17 pm    Post subject:
Reply with quote

Reread what you said and asked in your first post vs above post. Both don’t make sense they look contradictory.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2407
Location: @my desk

PostPosted: Tue Apr 24, 2018 7:25 pm    Post subject:
Reply with quote

neo4u,

Did you notice what prino had pointed out earlier? If you have any debugging tool (IBM Debug, Xpeditor etc..) you could run your test in batch using the tool, and set a break point after the SQL execution. Then overtype the SQLCODE value to the desired value and execute the rest of the program.
Back to top
View user's profile Send private message
bauer

New User


Joined: 03 Mar 2009
Posts: 28
Location: germany

PostPosted: Wed May 02, 2018 12:19 pm    Post subject:
Reply with quote

1) LOCK TABLE <yourTableWhereYouSelect> IN EXCLUSIVE MODE by SPUFI without commit
2) Execute your program, wait für SQL -904 after timeout
3) ROLLBACK in SPUFI the pending command from step (1)
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1563
Location: Andromeda Galaxy

PostPosted: Thu May 03, 2018 1:07 am    Post subject:
Reply with quote

There are many ways to test :

1. Ask your DBA to put the Tablespace in any of the pending status and when you try to access you get -904
2. Try to update the table without commit and so you get -911
3 As pointed by prino if you have a debugging tool you could override the SQL CODE at runtime.
..
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 Generate SQL query dynamically using ... vnktrrd DB2 7 Tue Aug 28, 2018 8:11 pm
No new posts Problem with Return or Exit from DCB ... Vishnu Priya M R PL/I & Assembler 6 Thu Aug 23, 2018 9:43 am
No new posts Query for fetching matching data in t... Poha Eater DB2 10 Mon Jul 09, 2018 6:06 pm
No new posts Varying List Select SQL Query In DB2 ... NikhilGuptaGaya DB2 5 Wed Jun 27, 2018 11:01 pm
No new posts SAS Work space - B37 abend santuece1 JCL & VSAM 11 Tue Jun 19, 2018 1:03 am

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