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



Pete, FYI -

We just upgraded to V5R4 last month, and V5R4 SQL does _some_ automatic casting of variable types for comparison purposes...

I found this out purely by accident a couple of weeks ago when I typed the following SQL statement:
Select *from F4211 where SDDOCO = '11674'

I would have expected an error, but in the above case SDDOCO is a numeric field and DB manager converted '11674' to the numeric value 11674 and it ran. On V5R2 this would have failed with an error.

On the other hand, the following SQL statement _does_ fail if I leave off the quotes:
Select *From F4211 where SDDCTO = SO

In this case, SDDCTO is an alphameric field, and it errors off with "Column SO not in specified tables."

- Steve

----- Original Message ----- From: "Pete Helgren" <Pete@xxxxxxxxxx>
To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx>
Sent: Thursday, September 06, 2007 1:56 PM
Subject: Re: Viewing the resultant SQL in an RPG program - RESOLVED


OK. Thanks for all the help and information. Although none of it
directly solved the issue, each little piece added another clue.

The actual problem was not the *LOVAL/*HIVAL stuff, it was that I was
concatenating single quotes to each of the character fields out of
habit. Apparently the compiler is smart enough to recognize a character
field as such and a numeric field as such and properly format the
statement when referencing the host variables. When I code in Java I
need to make sure that character fields have single quotes so that the
statement is formatted correctly.

Dropping the appending of the single quote constants did the trick. All
of which brings me back around to my original "wish": If I could have
seen the resultant SQL (warts and all) and could do a cut and paste in
to an interactive session I would have immediately seen the issue and
fixed it. A debug view that shows the SQL statement fully rendered and
as it would be executed would be a sweet addition. I would have seen this:

select * from myfile where
myssn between -999999 and 999999 and
myuser between ''PETE' ' and ''PETE' '

Which immediately I would have recognized as wrong.

Thanks to all,

Pete Helgren


Pete Helgren wrote:
It seems to be working as Joe indicated. I still don't see a recordset
when I run the SQL through RPG vs the interactive SQL session using the
hex representations of *LOVAL and *HIVAL so I don't know what is going
on, yet. I don't get records running the RPG version but if I run what
I assume the RPG version is running using interactive SQL, I do get
records. A few more hours of debugging and trial and error and I'll
figure it out.

Pete


vhamberg@xxxxxxxxxxx wrote:

I thought *LOVAL for character fields was x'40404040...' for the length of the field - it ought to be in the RPG Reference. It might be x'00000000...' for hex fields.

But then I'm not fully awake, so don't know for sure.

-------------- Original message -------------- From: "Joe Pluta" <joepluta@xxxxxxxxxxxxxxxxx>



From: Pete Helgren

I'll do some trial and error testing of the statement using different
variables and commenting portions of the statement and see if I can
figure out why the SQL is not returning records like I expect. The
*LOVAL/*HIVAL technique is a good one, I just need to know what to
submit in the SQL for *LOVAL and *HIVAL when the field is a 10 character
numeric.


Did you try x'00000000000000000000' and x' FFFFFFFFFFFFFFFFFFFF'?

Joe


--
This is the RPG programming on the AS400 / 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.



--
This is the RPG programming on the AS400 / 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.

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.