Re: CAST error during FETCH in SQLRPGLE program



I wonder about
> C+ IFNULL(B.ALCNO, ' ') = ' ' AND
> C+ (IFNULL(C.ALCNO, ' ') = ' ' OR
> C+ IFNULL(D.ALCNO, ' ') <> ' ')
Is ALCNO numeric by any chance? I think the two values in IFNULL have to be the same type...
the only other problem would be if the variables you're FETCHing into do not match type with the source fields.



SanderP wrote:
All,

I'm having a problem with a sqlrpgle program I'm working on;
Following cursor is defined:

C/EXEC SQL
C+     DECLARE          C00            CURSOR         FOR
C+     SELECT         A.ALCNO       ,
C+                    A.ORDNO       ,
C+                    A.ORDSNO      ,
C+                    A.ORGSNO      ,
C+                    A.CSTCD       ,
C+                    A.BNCCD       ,
C+                    A.PRDCD       ,
C+                    A.CLRCD       ,
C+                    A.DLVDT       ,
C+                    A.ALWHCD      ,
C+                    A.ALCAMT      ,
C+                    A.CURCOD      ,
C+                    A.CSTCDW      ,
C+                    A.BNCCDW      ,
C+                    A.ORDTP       ,
C+                    A.ALCBID
C+     FROM                  ALLOCDTL A
C+       LEFT OUTER JOIN     ALLOCCAN B
C+         ON         B.ALCNO      =   A.ALCNO        AND
C+                    B.ORDNO      =   A.ORDNO        AND
C+                    B.ORDSNO     =   A.ORDSNO
C+       LEFT OUTER JOIN     ALLOCSHP C
C+         ON         C.ALCNO      =   A.ALCNO        AND
C+                    C.ORDNO      =   A.ORDNO        AND
C+                    C.ORDSNO     =   A.ORDSNO
C+       LEFT OUTER JOIN     SHPINCAN D
C+         ON         D.ALCNO      =   C.ALCNO        AND
C+                    D.ORDNO      =   C.ORDNO        AND
C+                    D.ORDSNO     =   C.ORDSNO       AND
C+                    D.SINO       =   C.SINO         AND
C+                    D.SISNO      =   C.SISNO
C+     WHERE       A.CMPID      =  ' '             AND
C+                 A.ALWHCD     =  :P0WHCD         AND
C+                 A.VSRCD      =  :P0VSRCD        AND
C+                 A.PRDCD          =   :P0PRDCD        AND
C+                 A.CLRCD          =   :P0CLRCD        AND
C+                 A.ORDNO          >=  :C0ORDNO        AND
C+          IFNULL(B.ALCNO, ' ')    =   ' '             AND
C+         (IFNULL(C.ALCNO, ' ')    =   ' '  OR
C+          IFNULL(D.ALCNO, ' ')    <>  ' ')
C+     ORDER      BY  A.CSTCD     ASC   ,
C+                    A.BNCCD     ASC   ,
C+                    A.ORDNO     ASC   ,
C+                    A.ORDSNO    ASC
C/END-EXEC

After this the cursor is opened and the FETCH is done;

 *
C/EXEC SQL
C+     OPEN             C00
C/END-EXEC
 *
C                   DOW       NOT(*IN99)
 *
C/EXEC SQL
C+     FETCH            C00
C+     INTO            :S0ALCNO    ,
C+                     :S0ORDNO    ,
C+                     :S0ORDSNO   ,
C+                     :S0ORGSNO   ,
C+                     :S0CSTCD    ,
C+                     :S0BNCCD    ,
C+                     :S0PRDCD    ,
C+                     :S0CLRCD    ,
C+                     :S0DLVDT    ,
C+                     :S0WHCD     ,
C+                     :S0VSRCD    ,
C+                     :S0ALCAMT   ,
C+                     :S0CURCOD   ,
C+                     :S0CSTCDW   ,
C+                     :S0BNCCDW   ,
C+                     :S0ORDTP    ,
C+                     :S0ALBDID
C/END-EXEC
 * **

Immediately after the FETCH statement, SQLCOD has code -420.

Message text for this error is:
Character in CAST argument not valid.

Cause:
A character in the argument for the CAST function was
not correct.

Recovery Text:
Change the result data type to one that recognizes the
characters in the CAST argument, or change the
argument to contain a valid representation of a value for
the result data type. Try the request again.

I can't seem to find out why this error occurs.
Maybe some of the SQL guru's in here can help me :)

Thanks in advance,

Sander

.



Relevant Pages

  • Re: CAST error during FETCH in SQLRPGLE program
    ... C+ LEFT OUTER JOIN ALLOCCAN B ... C/EXEC SQL ... A character in the argument for the CAST function was not correct. ...
    (comp.sys.ibm.as400.misc)
  • Re: data conversion - varbinary to varchar
    ... The type varchar is the same as varchar. ... >Still not sure how to convert the data type. ... >>Using convert or cast, converts only the first character in the string. ...
    (microsoft.public.sqlserver.programming)
  • Re: Development news catch-up
    ... to topline a new original movie for the cable channel, ... Does Ponce have the chops to be the lead/recurring character? ... 10-to-1 says this means a new cast. ... "Summerland") is the latest addition to the comedy pilot, ...
    (rec.arts.tv)
  • Re: The importance of Kid Vulcan as a new X-Man?
    ... successful addition to the X-Men cast, primarily as a new X-Man. ... character will be the one to break this rut. ... Will it be Kid Vulcan? ... He's set to be the driver of the first Brubaker written Uncanny X-Men ...
    (rec.arts.comics.marvel.xbooks)
  • Re: The importance of Kid Vulcan as a new X-Man?
    ... successful addition to the X-Men cast, primarily as a new X-Man. ... character will be the one to break this rut. ... Will it be Kid Vulcan? ... He's set to be the driver of the first Brubaker written Uncanny X-Men ...
    (rec.arts.comics.marvel.xbooks)