× 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.



Yep - most likely the §CSEG column is NULL, because the LEFT JOIN isn't fulfilled.

Easiest way if to write

ifnull(§CSEG, 0)

instead.

HTH
Daniel



Von meinem iPhone gesendet
Am 12.06.2024 um 12:49 schrieb Sean Courtney <scourtney@xxxxxxxxxxx>:

Hi ,

You most likely have NULL content so you must either catch this with
NULL-Indicators on each select into variable or
use the scalar function COALESCE to set NULL to a default value

Mit freundlichen Grüßen / Kind regards / Bien à vous,

Seán


Confidentiality Notice:

This message and any attachments may contain confidential and privileged
information. The information contained herein is transmitted for the sole
use of the intended recipient(s). If you are not the intended recipient or
designated agent of the recipient of such information, please notify the
sender immediately and permanently delete this email. Thank You


-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of gio.cot
via RPG400-L
Sent: Wednesday, 12 June 2024 12:44
To: 'RPG programming on IBM i' <rpg400-l@xxxxxxxxxxxxxxxxxx>
Cc: gio.cot <gio.cot@xxxxxxxxxxx>
Subject: Error SQL 22002

Hi all

In a RPG program execute SQL : below what i do:

when i run the program i receive SQL Error 22002 An indicator variable is
required.



Where am i wrong ? how can solve this error ?






Dcl-Ds MainDs;

xAnnoc Char(2);

xMesec Char(2);

xImpo Packed(30:9);

End-Ds;





mainStatement = ' SELECT '

+ ' Substr(xdtr, 1, 2), '

+ ' Substr(xdtr, 3, 2), '

+ ' SUM((xqty * (prc - xsc) ) * §CSEG ) AS impo '

+ ' FROM myfile m '

+ ' left join myile 2 t '

+ ' on xcax = §cax '

+ ' Group by substr(xdtr, 1, 2) , substr(xdtr, 3, 2)'

+ ' order by substr(xdtr, 1, 2) , substr(xdtr, 3,2)';



ExEC SQL

FETCH NEXT FROM mainCursor INTO :MAINDS ;







--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.


--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.