Need a better display for sql code.



IBM's flagship relational database management system

Need a better display for sql code.

Postby Dashimir » Tue Mar 26, 2013 6:00 pm

In my program there is a select clause than i move sqlcode to a variable and display it, when it goes to an if(diferent from zeros) clause for an error routine it enters that -if but the display is 00000000. First i thought this had no logic then i wanna know if there is a better way to do this i apreciate your help thx.

select xxxx
into xxx
from xxx
where xxx
end exec

move sql code to variable
display variable
if sql code not equal zeros
perfor error routine ....


I get display 00000000 from display variable

Thank you in advance.
Dashimir
 
Posts: 42
Joined: Wed Dec 26, 2012 7:27 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Need a better display for sql code.

Postby NicC » Tue Mar 26, 2013 6:44 pm

display sql code before assigning it to 'variable' to confirm what it thinks it has. Maybe it really is zero.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

666 post

Postby Dashimir » Tue Mar 26, 2013 6:47 pm

By the way this is the 666 post =D.
Dashimir
 
Posts: 42
Joined: Wed Dec 26, 2012 7:27 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Need a better display for sql code.

Postby Dashimir » Tue Mar 26, 2013 6:51 pm

00000000 what is the logic ?

If sqlcode is not equal zeros
display sqlcode
end-if.

how can this display be zeros ?
Dashimir
 
Posts: 42
Joined: Wed Dec 26, 2012 7:27 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Need a better display for sql code.

Postby NicC » Tue Mar 26, 2013 6:55 pm

That is not what your pseudo code says. It says move the sql code to a variable and display it. THEN if the code is not zero perform the error routine so you are ALWAYS displaying the code.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Need a better display for sql code.

Postby Dashimir » Tue Mar 26, 2013 7:00 pm

exec
end-exec.
IF SQLCODE NOT EQUAL 100 OR 0
PERFORM R-9998-00-ERRO
GO TO R-2000-SAIDA
END-IF

I dont move it before.
and after i have
display sql code wich comes with zeros
Dashimir
 
Posts: 42
Joined: Wed Dec 26, 2012 7:27 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Need a better display for sql code.

Postby Robert Sample » Tue Mar 26, 2013 7:09 pm

Why do programmers not learn DeMorgan's laws?

IF SQLCODE NOT EQUAL 100 OR 0
is a short form for
IF SQLCODE NOT EQUAL 100 OR SQLCODE NOT EQUAL 0
and if SQLCODE is 0 then it is not equal to 100 -- TRUE condition; if SQLCODE is 100 then it is not equal to 0 -- TRUE condition; if SQLCODE is anything else it is not equal to 100 and it is not equal to 0 -- TRUE condition. In other words, you're going to do the PERFORM / GOTO no matter what the value of SQLCODE is.

Note that this is a good example of why we on this forum want to see code -- your original post has a DISPLAY with no IF logic, and the IF statement you posted only has one condition (so DeMorgan's Laws don't apply).

These users thanked the author Robert Sample for the post:
Dashimir (Tue Mar 26, 2013 7:31 pm)
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Need a better display for sql code.

Postby Dashimir » Tue Mar 26, 2013 7:24 pm

Hum then i interpreted this wrong.

tried like this:
EVALUATE SQLCODE             
  WHEN ZEROS                 
    CONTINUE                 
  WHEN 100                   
    CONTINUE                 
  WHEN OTHER                 
    PERFORM R-9998-00-ERRO   
    GO TO R-2000-SAIDA       
END-EVALUATE
Code'd

still go to erro.
Dashimir
 
Posts: 42
Joined: Wed Dec 26, 2012 7:27 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Need a better display for sql code.

Postby dick scherrer » Tue Mar 26, 2013 8:45 pm

Hello,

First, you should use the Code tag to improve readability and preserve alignment.

Second, please insert a DISPLAY 'BEFORE EVALUATE = ' SQLCODE immediately before the EVALUATE statement and post the output.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Need a better display for sql code.

Postby Dashimir » Tue Mar 26, 2013 9:26 pm

U were absolutly right =D thx.
Dashimir
 
Posts: 42
Joined: Wed Dec 26, 2012 7:27 pm
Has thanked: 2 times
Been thanked: 0 time


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post