The concat predicate must be specified outside the CASE clause.
Select orgno concat '-' concat major concat '-' concat
Case
When sub < 10 THEN
right('00' concat Rtrim(SUBSTR(sub,1,3)), 3)
When sub >= 10 and sub < 100 THEN
right('0' concat Rtrim(SUBSTR(sub,1,3)), 3)
Else sub
End as FullGL, ....
But why to use a case clause at all?
The following statement should do the same:
Select orgno concat '-' concat major concat '-' concat
Right('000' concat RTrim(Substr(sub, 1, 3)), 3)
as FullGL,
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Jim Minisce
Gesendet: Thursday, 28.2 2013 23:57
An: RPG programming on the IBM i (AS/400 and iSeries)
Betreff: SQL Case Frustration
Hi Everyone,
It has been awhile since I have asked for assistance from the group but
but rest assured that I have been diligently lurking. I am having a tuff
time with the below SQL statement and I do not know why, could be due the
time of day. I am working on developing an embedded SQL statement within a
RPG program to extract G/l data from my company's ERP application. I would
like to use the Case statement to ensure the sub account code is formatted
correctly when I convert the numeric values to character. ex when the sub
account = 0, then '000'; when the sub account = 10, then '010'; when the sub
account = 100, then '100'.
Here is what I have so far:
Select orgno concat '-' concat major concat '-'
Case
When sub < 10 THEN
concat right('00' || Rtrim(SUBSTR(sub,1,3)), 3)
When sub >= 10 and sub < 100 THEN
concat right('0' || Rtrim(SUBSTR(sub,1,3)), 3)
Else
concat sub
End as FullGL,
net2,ytd2 from glsum12 where orgno = 30 and major between 97319 and 97456
order by major
The interactive SQL session is yelling at me, saying that the Case keyword
is not expected at line 2.
Any help would be greatly appreciated!!
Jim Minisce
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.