Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Learn all there is to know about SQL on the AS/400

129 views
Skip to first unread message

Cole

unread,
Oct 16, 2002, 11:10:04 AM10/16/02
to
Hello,

I am looking for some good sites to learn about programming SQL on
the AS/400. I have the pdf versions of the manuals but what I'm
looking for are examples of good SQL code and how people are using it.
One thing I would like to be able to do is to convert queries that
are created with the Query tool to queries that can be run in Query
Manager. Also I have a bunch of queries that we use both types of
queries to come up with a final file and I'd like to be able to
combine them into one clean process using just the Query Manager.

Thanks,

Cole

Rikkie

unread,
Oct 16, 2002, 1:55:54 PM10/16/02
to
I have some urls on my site.
Goto http://users.skynet.be/vecelzo and select Query.

"Cole" <cole...@yahoo.com> wrote in message
news:38a074e8.02101...@posting.google.com...

Sam L.

unread,
Oct 16, 2002, 7:49:08 PM10/16/02
to
You do know that you can convert Query/400 queries to QM Queries
using RTVQMQRY? You need to prompt it and specify
ALWQRYDFN(*YES). (I think that is the right keyword.)

You'll get source that can be "compiled" with the CRTQMQRY
command and the resultant object run with the STRQMQRY command.

Be aware, however, that it doesn't do an adequate job of type 2
or type 3 queries. You'll need to tweak these your self using
the "from file1 left join file 2 on F1key1=F2key2 and
F1Key2=F2Key2" kind of syntax.

I don' care a lot for how it formats the statement either, but
you can always clean it up in an editor.

Sam

"Cole" <cole...@yahoo.com> wrote in message
news:38a074e8.02101...@posting.google.com...

Drew Dekreon

unread,
Oct 16, 2002, 9:01:35 PM10/16/02
to
are you familiar with SQL in general?
If not, I'd recommend trying out microsoft access or msqry32.exe (part
of excel - called in when you do New Database Query).
You can prompt through making various types of queries (select, update,
delete), then switch to SQL mode & view the actual statement -- very
useful for learning this stuff!
as for integration to RPG, I'd recommend Cozzi's book Modern RPG. Great
appendix that lays out how to make the jump from pure rpg to sqlrpg.

Cole

unread,
Oct 17, 2002, 8:40:35 AM10/17/02
to
Yes, I'm familar with SQL. It's just difficult wading through all of
the stuff with the AS/400. There are a lot of different tools
available but tough to know the right questions to ask to get done
what I need to do. I need to work native on the 400 for speed. The
tables that I'm accessing have millions of records and to larger to
work with through ODBC.

Cole

Drew Dekreon <drew_d...@chugachelectric.com.x.com> wrote in message news:<uqs2vdt...@corp.supernews.com>...

Cole

unread,
Oct 17, 2002, 8:47:54 AM10/17/02
to
No Sam I didn't. Thanks for the info, I'll check that out today. Any
other bits of information? Is it possible to combine multiple SQL
queries into one job stream without using CL? For example let's say I
need to create a summary of costs of inventory items and then link
that summary file to another table to get additional information and
then output that file to build an excel spreadsheet.

Thanks,

Cole


"Sam L." <none...@nonesuch.com> wrote in message news:<Senr9.201$g64....@eagle.america.net>...

Phil

unread,
Oct 17, 2002, 10:34:22 AM10/17/02
to
Do you know that you can use the RUNSQLSTM command within a CL program or
interactively from the qcmd screen provided that you need not pass
parameters to the statements included in the source file member ?
You can even use multiple sql statements in the *same* member provided that
you separate each one with a semicolon (;)

HTH
Phil

"Cole" <cole...@yahoo.com> a écrit dans le message de news:
38a074e8.02101...@posting.google.com...

Kent Milligan

unread,
Oct 17, 2002, 5:42:08 PM10/17/02
to
As long as you're not returning 1 million rows to the ODBC application, ODBC SQL
is going to perform the same on large tables as "native" AS/400 SQL.

--
Kent Milligan, DB2 & BI team
PartnerWorld for Developers, iSeries
km...@us.removethis.ibm.com GO HAWKEYES!!
>>> www.iseries.ibm.com/db2
(opinions stated are not necessarily those of my employer)


Sam L.

unread,
Oct 17, 2002, 8:39:15 PM10/17/02
to
CL is the scripting language of the AS/400 (iSeries) so you are
kind of stuck with it.

Some one has pointed you to RUNSQLSTM to run a series of SQL
statements, each terminated with a ";", from a source file. Be
aware that all you can do by way of output is "INSERT INTO myFile
(SELECT SUM(AnyFile) FROM AnyFile)" type of stuff, though this
isn't a huge restriction, and you can't pass parameters. With
*QMQRY you can do "SELECT SUM(AnyFile) FROM AnyFile" and create a
new file on the fly, though I believe the output data is
processed twice.

If you go with "compile" *QMQRY type objects you can pass in
parameters, but you are restricted to single SQL statements, thus
you need to string them together with CL.

SQL facilities on the AS/400:

STRSQL (interactive SQL.)

STRQM (interactive building of *QMQRY objects.)

Embedded SQL in RPG or Cobol.

SQL stored procedures written in SQL procedural language. (Used
to require a C compiler, but as of V5R1 or V5R2 the compiler is
no longer necessary.)

The above need the SQL Development Kit, an extra cost option.

RUNSQLSTM (runs one or more SQL statements from a source file.)

CRTQMQRY (build *QMQRY objects from source)

STRQMQTY (run *QMQRY objects.)

Sam


"Cole" <cole...@yahoo.com> wrote in message
news:38a074e8.02101...@posting.google.com...

Karl Hanson

unread,
Oct 17, 2002, 9:56:24 PM10/17/02
to

A few more:
-- iSeries Access (aka Client Access) has a Run SQL Scripts facility
-- CLI API is part of OS/400, which is like ODBC
-- JDBC

--
Karl Hanson

Sam L.

unread,
Oct 17, 2002, 11:14:14 PM10/17/02
to

"Karl Hanson" <kcha...@youess.ibm.com> wrote in message
news:3DAF6A48...@youess.ibm.com...

> A few more:
> -- iSeries Access (aka Client Access) has a Run SQL Scripts
facility

I presume you mean in iSeries Navigator, formerly Operations
Navigator, which is an optional installed part of iSeries Access.
(Or am I confused about the names? I just love trying to keep up
with IBM's product names.)

Peter Gulutzan

unread,
Oct 20, 2002, 1:09:34 PM10/20/02
to
cole...@yahoo.com (Cole) wrote in message news:<38a074e8.02101...@posting.google.com>...

> Yes, I'm familar with SQL. It's just difficult wading through all of
> the stuff with the AS/400. There are a lot of different tools
> available but tough to know the right questions to ask to get done
> what I need to do. I need to work native on the 400 for speed. The
> tables that I'm accessing have millions of records and to larger to
> work with through ODBC.
>
> Cole
>
There have been several books about this topic over the years. Some
(like "SQL/400 By Example" and "SQL/400: A professional programmer's
guide") are getting a bit obsolete now, but Conte + Cravitz's "SQL/400
Developer's Guide (Conte and Cravitz)" 2nd edition is from 2000 and
has 4.5 stars on amazon. There's also "iSeries and AS/400 SQL at Work"
and "Database Design and Programming for DB2/400".

Peter Gulutzan
www.ocelot.ca
Co-Author of SQL Performance Tuning (http://www.ocelot.ca/tuning.htm)

0 new messages