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

How to force a select query to abend


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

New User


Joined: 03 Oct 2016
Posts: 5
Location: India

PostPosted: Mon Apr 23, 2018 1:36 pm
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
Warnings : 1

Senior Member


Joined: 07 Feb 2009
Posts: 1241
Location: Vilnius, Lithuania

PostPosted: Mon Apr 23, 2018 7:16 pm
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

Global Moderator


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

PostPosted: Mon Apr 23, 2018 7:40 pm
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: 5
Location: India

PostPosted: Tue Apr 24, 2018 11:28 am
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

Global Moderator


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

PostPosted: Tue Apr 24, 2018 1:17 pm
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: 2481
Location: @my desk

PostPosted: Tue Apr 24, 2018 7:25 pm
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
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: 1565
Location: Andromeda Galaxy

PostPosted: Thu May 03, 2018 1:07 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Help in writting SQL query DB2 1
No new posts Need Help with on of the coalesce query DB2 4
No new posts ABEND=04E FOR REASON=00E50013 DB2 4
No new posts Any idea about how to solve 3022 aben... IMS DB/DC 3
No new posts Handling abend to prevent termination CICS 0
Search our Forums:

Back to Top