Page 1 of 1

Need a better display for sql code.

PostPosted: Tue Mar 26, 2013 6:00 pm
by Dashimir
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.

Re: Need a better display for sql code.

PostPosted: Tue Mar 26, 2013 6:44 pm
by NicC
display sql code before assigning it to 'variable' to confirm what it thinks it has. Maybe it really is zero.

666 post

PostPosted: Tue Mar 26, 2013 6:47 pm
by Dashimir
By the way this is the 666 post =D.

Re: Need a better display for sql code.

PostPosted: Tue Mar 26, 2013 6:51 pm
by Dashimir
00000000 what is the logic ?

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

how can this display be zeros ?

Re: Need a better display for sql code.

PostPosted: Tue Mar 26, 2013 6:55 pm
by NicC
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.

Re: Need a better display for sql code.

PostPosted: Tue Mar 26, 2013 7:00 pm
by Dashimir
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

Re: Need a better display for sql code.

PostPosted: Tue Mar 26, 2013 7:09 pm
by Robert Sample
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).

Re: Need a better display for sql code.

PostPosted: Tue Mar 26, 2013 7:24 pm
by Dashimir
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.

Re: Need a better display for sql code.

PostPosted: Tue Mar 26, 2013 8:45 pm
by dick scherrer
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.

Re: Need a better display for sql code.

PostPosted: Tue Mar 26, 2013 9:26 pm
by Dashimir
U were absolutly right =D thx.