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



Jack

Glad to hit the target once in awhile. I ran into a similar issue when I first tried IN - SQL seems different, where IN and NOT IN are both called operators. At least in one example, I get the same results -

select * from qiws/qcustcdt where not state in ('NH', 'AK');

vs.

select * from qiws/qcustcdt where state not in ('NH', 'AK');

And the version with parentheses also gives the same result -

select * from qiws/qcustcdt where not (state in ('NH', 'AK'));

I suppose one has to say that the context is different in RPG, but it's still kind of confusing, seems to me. And the SQL Reference didn't seem to have a clear precedence table that I could find.

Cheers
Vern

On 8/17/2023 6:05 AM, Jack Callahan wrote:
Vern:

Thanks for the on the money response.

i usually wrapper my logical expressions in parentheses but hadn't
considered that for my first use of IN.

Jack

On Thu, Aug 17, 2023 at 6:39 AM Vern Hamberg<vhamberg@xxxxxxxxxxxxxxx>
wrote:

Hi Jack

I put your code into RDi with declarations and filled the array. I got
the same error. The nice thing about RDi is, it highlighted the exact
point of the error - it said that " data_type", the element, was not
compatible with an operator - that operator is "NOT". The compile
listing, even with *SECLVL, doesn't help here.

Problem is hierarchy of operations. Seems "NOT" is done first here,
before "IN".

So it works to put parenthese around the IN expression, as here -

IF NOT (FV(i).data_type IN %list('NUMERIC' :'CHAR'));

So I recommend using RDi with *EVENTF compile option and interactive
compile.

Regards
Vern

On 8/16/2023 10:04 PM, Jack Callahan wrote:
Have an data structure FV to hold column details for a given table loaded
using SQL FETCH including a column data_type defined as a varchar(8).
RowsFetched contains the number of columns defined. I would like to
verify
that all the data_types defined agree to a list of values ('NUMERIC' or
'CHAR'). Tried a code snippet looks something like this:

isValid = '1';
FOR i=1 TO RowsFetched;
IF NOT FV(i).data_type IN %list('NUMERIC' :'CHAR');
isValid = '0';
ENDIF;
ENDFOR;

Compile fails with RNF7421, to wit:

"Operands are not compatible with the type of operator.

Cause . . . . . : Operands must be of class character, graphic, or UCS-2
for character operations; numeric for arithmetic operations; and
indicator
for logical and relational operations. In a comparison operation, both
operands must have the same data type. The specification is ignored."
Obviously I can convert the IN to a compound logical comparison to make
the program work.
What I'd like to learn is what data type is being assigned to the %list
expression terms. I can't seem to make the terms compatible. Or is the
problem using an element of the data structure as one of the terms? Or is
it something else altogether?

Any thoughts welcome

Jack


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.