× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi, Folks:



I have the following code in an ILE RPG program at V5R4, and it fails at the
FETCH with an SQL0420 error (Character in CAST argument not valid). I have
added the CAST() functions as you see here in an effort to eliminate the
error, but no go. I am sure that I'm overlooking something, but it evades
me completely. Can you help? I believe that everything pertinent to this
question is below.



<snip>

P topDefects B

D topDefects PI

D fromDate D Value

D toDate D Value



D department S 64 Varying

D deptSeq S 10I 0

D rank S 5U 0

D reason S 32 Varying

D totQty S 10I 0

<snip>

/Free

GatherStats('Processing: "Top Defects"') ;

<snip>

Exec SQL DECLARE topDefCursor03 CURSOR FOR

WITH ranker AS (

SELECT REASON, SUM(QUANTITY) as WRKQTY

, row_number() over(ORDER BY SUM(quantity) DESC) as RANK

FROM BRKDATA

WHERE data_date BETWEEN :fromDate AND :toDate

AND department > ' '

GROUP BY REASON)

, summary as (

SELECT DEPTSEQ, REASON, SUM(QUANTITY) AS totQty

FROM BRKDATA

WHERE data_date BETWEEN :fromDate AND :toDate

GROUP BY REASON, DEPTSEQ)

SELECT CAST(R.RANK AS INT)

, CAST(D.COLNBR AS INT)

, CAST(S.REASON AS VARCHAR(32))

, CAST(S.totQty AS INT)

FROM summary S

JOIN ranker R ON S.REASON = R.REASON

JOIN QTEMP/TOPDEPTS D on S.DEPTSEQ = D.DEPTSEQ

WHERE R.RANK <= 75

ORDER BY R.RANK

;

checkSQL(EOF_OK: SQL_ABORT: 'topDefCursor03') ;

Exec SQL OPEN topDefCursor03 ;

checkSQL(EOF_OK: SQL_ABORT: 'topDefCursor03-A') ;

Exec SQL FETCH topDefCursor03 INTO :colNbr, :reason, :totQty ;

DoW SQLCOD = *Zero ;

<snip>

Exec SQL FETCH topDefCursor03 INTO :colNbr, :reason, :totQty ;

EndDO ;

checkSQL(EOF_OK: SQL_ABORT: 'topDefCursor03-B') ;

Exec SQL CLOSE topDefCursor03 ;

<snip>

Thanks,

Dennis E. Lovelady
AIM: delovelady MSN: fastcounter@xxxxxxxxxxxx
<http://www.linkedin.com/in/dennislovelady>
www.linkedin.com/in/dennislovelady --
"Opportunity is missed by most people because it is dressed in overalls and
looks like work."
- Thomas Edison




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.