Page 1 of 1

SQLCODE -310 on select statement?

PostPosted: Tue Jan 04, 2011 7:27 am
by fornanthakumar
Hi,
I have an query in my application program like below,
 EXEC SQL                                             
       SELECT CENTR_NAME_X,                           
              CENTR_TYPE_C,                           
              HMLN_RGION_N                           
         INTO :CENTR-NAME-X,                         
              :CENTR-TYPE-C,                         
              :HMLN-RGION-N                           
         FROM HMLN.ONLIN_CENTR                       
        WHERE CENTR_IBT_N = :DCLHMLN-RGSTN.RGION-IBT-N
        WITH UR                                       
 END-EXEC. 


both CENTR_IBT_N and DCLHMLN-RGSTN.RGION-IBT-N declared as decimal (5,0) not null. The actual value of DCLHMLN-RGSTN.RGION-IBT-N is 00000.

While the program was executing, i have got an ABEND with SQLCODE is -31} (-310). Which is DECIMAL HOST VARIABLE OR PARAMETER number CONTAINS NON-DECIMAL DATA. I was puzzled here because while i execute the same query in spufi like below

SELECT CENTR_NAME_X,                           
              CENTR_TYPE_C,                           
              HMLN_RGION_N  FROM HMLN.ONLIN_CENTR                       
        WHERE CENTR_IBT_N = 00000;
I have got an empty result set.

Someone please help out on this.?

Re: SQLCODE -310 on select statement?

PostPosted: Tue Jan 04, 2011 11:39 am
by dick scherrer
Hello,

The literal 00000 is valid - the host variable is not. . .

How is this defined and what value is in this variable when the problem occurs?

Re: SQLCODE -310 on select statement?

PostPosted: Sat Jan 08, 2011 11:27 pm
by fornanthakumar
Hi,

Both the predicate CENTR_IBT_N and the host varibale :DCLHMLN-RGSTN.RGION-IBT-N defined as DECIMAL ( 5 , 0).

I moved zeroes to host variable :DCLHMLN-RGSTN.RGION-IBT-N.

But i am facing -310 as SQLCODE. Please clarify.

Re: SQLCODE -310 on select statement?

PostPosted: Sun Jan 09, 2011 9:27 am
by dick scherrer
Hello,

Well, i surely believe db2. . . Somehow the host variable CONTAINS NON-DECIMAL DATA when the sql is executed.

Suggest you show the hex value of the variable immediately before executing the SELECT.