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



So you added a CASE clause that adds a new column based on t1.OhComp, and added that new column to the ORDER BY. What happens if you add t1.OhComp directly?



-----Original Message-----
From: Craig Richards [mailto:craig@xxxxxxxxxxxxxxxx]
Sent: Tuesday, March 12, 2019 4:43 AM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: SQL Internal Error

Hi All,

I'm getting an SQL System Error from one of my subprocedures and it looks like an embedded SQL bug to me.

To be precise, the code is running and returning SqlCode -901, SqlState
58004 and producing a couple of spooled files:
DBOPTRC198, QSQSVCDMP, QDSPJOB

The text retreived from:
Get Diagnostics Condition 1 :ErrorMsg = MESSAGE_TEXT is returning "SQL System Error".

I would appreciate it if anyone could have a quick look at the SQL and my problem description and double check I'm not being a buffoon (in this matter at least...) Below are links to two versions of the SQL - one which works and one which fails and the only difference is an extra field in the main select and final group by.

My best understanding of what is causing the internal error is that the GROUP BY clause only contains host variables, plus a field on the main WHERE clause which also refers to a host variable.
When I run the code in Squirrel SQL client (which prompts for host variables it sees in the SQL) it runs fine - so it would seem to be an issue with the embedded SQL.

This code works fine:
https://code.midrange.com/8ed534b6cc.html

But this code fails as described above:
https://code.midrange.com/8c22090c16.html

And the only difference between the two of them is that I dropped a field which was not required from the main SELECT and the final GROUP BY:

From the working version:
Line 7 is dropped (it builds a field called ShipComplete from t1.OhComp) Line 57 - r.ShipComplete is removed from the GROUP BY.

So that leaves in the GROUP BY:
1. r.OhOrdr which is part of the primary Where clause, and based on a Host Variable (hence constant for the data set) 2. r.NumLines which is a Host Variable and therefore constant for the data set.

As I mentioned above, cutting and pasting the exact code from the program source to run in Squirrel SQL client, ran successfully.

Thanks to any/all who might have time for a quick look at this.
best regards,
Craig


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.